admin管理员组文章数量:1022935
I am using this code to get the response:
<fb:like layout="button_count" notify="true" colorscheme="dark" href=""></fb:like>
<script>
// this will fire when any of the like widgets are "liked" by the user
FB.Event.subscribe('edge.create', function(href, widget) {
alert('You liked ' + href, widget);
});
</script>
It's not giving any response. Can anyone tell what wrong am i doing ?
I am using this code to get the response:
<fb:like layout="button_count" notify="true" colorscheme="dark" href="http://www.fbrell."></fb:like>
<script>
// this will fire when any of the like widgets are "liked" by the user
FB.Event.subscribe('edge.create', function(href, widget) {
alert('You liked ' + href, widget);
});
</script>
It's not giving any response. Can anyone tell what wrong am i doing ?
Share Improve this question asked Jan 7, 2012 at 19:38 Pankaj SharmaPankaj Sharma 6796 silver badges12 bronze badges 1- Your sample is just working correctly. Do you have any errors on page before? Does number of likes increases once you pressing the "Like Button"? – Juicy Scripter Commented Jan 7, 2012 at 19:56
3 Answers
Reset to default 1Assuming that you have the FB Like button appearing, so you must be including the SDK correctly, I was in exactly the same situation - all you're missing is setting the subscribe up in the fbAsyncInit() function.
window.fbAsyncInit = function () {
FB.Event.subscribe('edge.create', function (targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);
});
};
If you're doing this you don't need an application ID nor do you you need to use the FBML code, you can use the HTML5 inclusion code like <div class='fb-like' data-href='...
- You're missing the inclusion of the javascript SDK files.
- You're missing the FB.init
- You're not running your code within the fbAsyncInit() function.
See https://developers.facebook./docs/reference/javascript/ for more information.
Checklist:
(Im assuming you have setup the Javascript SDK)
run the FB linter on your url, errors here may stop it working
http://developers.facebook./tools/debug
Include this at the top of the page
<html xmlns="http://www.w3/1999/xhtml" xmlns:fb="http://www.facebook./2008/fbml">
If your liking an app, include on your app page
<meta property="fb:app_id" content="Your app id" />
Like button, change href to your link
<fb:like layout="button_count" show_faces="false" height="21" href="http://facebook."></fb:like>
If its an app, FB prefers HTTPS
function init() {
FB.init({
appId: APP_ID,
status: true,
cookie: true,
xfbml: true,
oauth: true
});
//unment if required
//window.fbAsyncInit = function() {
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
}
);
//}
}
init();
I am using this code to get the response:
<fb:like layout="button_count" notify="true" colorscheme="dark" href=""></fb:like>
<script>
// this will fire when any of the like widgets are "liked" by the user
FB.Event.subscribe('edge.create', function(href, widget) {
alert('You liked ' + href, widget);
});
</script>
It's not giving any response. Can anyone tell what wrong am i doing ?
I am using this code to get the response:
<fb:like layout="button_count" notify="true" colorscheme="dark" href="http://www.fbrell."></fb:like>
<script>
// this will fire when any of the like widgets are "liked" by the user
FB.Event.subscribe('edge.create', function(href, widget) {
alert('You liked ' + href, widget);
});
</script>
It's not giving any response. Can anyone tell what wrong am i doing ?
Share Improve this question asked Jan 7, 2012 at 19:38 Pankaj SharmaPankaj Sharma 6796 silver badges12 bronze badges 1- Your sample is just working correctly. Do you have any errors on page before? Does number of likes increases once you pressing the "Like Button"? – Juicy Scripter Commented Jan 7, 2012 at 19:56
3 Answers
Reset to default 1Assuming that you have the FB Like button appearing, so you must be including the SDK correctly, I was in exactly the same situation - all you're missing is setting the subscribe up in the fbAsyncInit() function.
window.fbAsyncInit = function () {
FB.Event.subscribe('edge.create', function (targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);
});
};
If you're doing this you don't need an application ID nor do you you need to use the FBML code, you can use the HTML5 inclusion code like <div class='fb-like' data-href='...
- You're missing the inclusion of the javascript SDK files.
- You're missing the FB.init
- You're not running your code within the fbAsyncInit() function.
See https://developers.facebook./docs/reference/javascript/ for more information.
Checklist:
(Im assuming you have setup the Javascript SDK)
run the FB linter on your url, errors here may stop it working
http://developers.facebook./tools/debug
Include this at the top of the page
<html xmlns="http://www.w3/1999/xhtml" xmlns:fb="http://www.facebook./2008/fbml">
If your liking an app, include on your app page
<meta property="fb:app_id" content="Your app id" />
Like button, change href to your link
<fb:like layout="button_count" show_faces="false" height="21" href="http://facebook."></fb:like>
If its an app, FB prefers HTTPS
function init() {
FB.init({
appId: APP_ID,
status: true,
cookie: true,
xfbml: true,
oauth: true
});
//unment if required
//window.fbAsyncInit = function() {
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
}
);
//}
}
init();
本文标签: javascriptFBEventsubscribe code not workingStack Overflow
版权声明:本文标题:javascript - FB.Event.subscribe code not working - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745492364a2153017.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论