FB comment plugin gives 500 error. FB.Event.Subscribe("comment.create',callback) is fired but does not return successfully instead throws a 500 error.However,this only happens on the first comment.The post still goes through and appears as comment on page reload.
However,on the same post,when replying to the posted comment,it fires the event without any errors.
I am using facebook comment plugin and my setup is that i create dynamic url by getting data from the database and then create url based on that on front end.I am using knockout on the front end and flask at the backend.My goal here is to utilise FB comment plugin as threaded comment on each post.I am triggering push notifications when someone comments on the post by looking at the id of the post.
//HTML
<div data-bind="text:$data.location,
click:window.animateMarkerOnClick.bind($data), attr: { id:
$data.key,class:'search-list' }"></div>
<div id="listing-msg" >
</div>
<div class="fb-comments" data-bind='attr:{"href":
"http://localhost:8080/postit/get_share_listings/#" +
$data.key,"id":$data.key}' data-width="320" data-numposts="1" data-
colorscheme = "dark" notify = "true" data-order-by = "reverse_time"></div>
//JS EVENT SUBSCRIPTION
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxx',
autoLogAppEvents : true,
xfbml : true,
version : 'v3.2'
});
FB.Event.subscribe("comment.create", push)
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
//callback
function push(){
$.ajax({
type: "POST",
url: "http://localhost:8080/postit/push",
contentType: 'application/json;charset=UTF-8',
data:JSON.stringify({"data":document.activeElement.
parentElement.parentElement.parentElement.children[0].id})
})
}
As already stated,the event triggers callback but on first comment facebook triggers url handler createComment which gives 500 but createReply successfully triggers the callback.
The
comment.create
event does not exist any more in the JS SDK.https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v3.2 does not mention it any more, when you click the down arrow next to
event
, and https://developers.facebook.com/support/bugs/927463134113943/?comment_id=930637043796552 confirms it is gone: “comment.create is officially killed.”You need to use server-side webhooks now, if you want your app to get notified about new comments made via the comments plugin, see https://developers.facebook.com/docs/graph-api/webhooks/reference/application/#plugin_comment