Facebook's new fb:comments and FB.Event.subscribe 'comments.create' not working
Any help will be deeply appreciated as I've tried everything I can think of to get this going but to no avail.
I am using Facebook's updated (as of last week) fb:comments system but can not get the FB.Event.subscribe 'comments.create' and FB.Event.subscribe 'comments.remove' to work.
The page in question can be seen here.
I am initialising FB Asynchronously:
<script type="text/javascript">
//<![CDATA[
window.fbAsyncInit = function() {
FB.init({appId: '191116444251564', status: true, cookie: true, xfbml: true});
FB.开发者_如何学PythonEvent.subscribe('comments.create', function (response) {
// console.log('create', response);
//got response.... now query FQL to return total number of post counts
FB.api(
{
method: "fql.query",
query: "SELECT count FROM comments_info WHERE xid='2_plain-basmati-rice---rice-cooker' and app_id='191116444251564'"
},
function(fql_response) {
$j.post('/recipes/2_plain-basmati-rice---rice-cooker/commented', {count: fql_response[0].count});
}
);
});
FB.Event.subscribe('comments.remove', function (response) {
//got response.... now query FQL to return total number of post counts
// console.log('remove', response);
FB.api(
{
method: "fql.query",
query: "SELECT count FROM comments_info WHERE xid='2_plain-basmati-rice---rice-cooker' and app_id='191116444251564'"
},
function(fql_response) {
$j.post('/recipes/2_plain-basmati-rice---rice-cooker/commented', {count: fql_response[0].count});
}
);
});
};
(function() {
var e = document.createElement('script');
e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
//]]>
</script>
replacing both subscribe callbacks with a simple alert('tst') doesn't work.
I've tested the page using FB's linter and no errors show up for that particular page.
Again, my thanks to anyone whole could offer any tips or pointers.
I think the Event.subscribe is a little shaky at the moment. I had similar code working last week (around March 8) but today (March 13) I noticed that the Event.subscribe is not firing. BTW, I think it is now supposed to be comment.create, not comments.create. That is what was working for me.
Unreliable sources say Facebook's FQL is going to be updated soon to accommodate functions for the new comment system... We're all waiting.
You read Facebook's documentation? That's a big mistake unfortunately.
Try with comments.add instead of comments.create...
It is comment.create, that should work.
精彩评论