Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FB.event.subscribe('comment.create') doesn't work

Tags:

facebook

I am trying to get a notification when an user comments using the social plugin. The code is as following:

<fb:comments href='someurl' width='400'></fb:comments>
FB.Event.subscribe('comment.create', function(response)
{
 alert(response);
}

Simple, but it's not working. Someone got some possible errors? From my research online, it seems as if the notification has no real consistency. Sometimes it works, sometimes it doesn't.

like image 972
nambrot Avatar asked May 27 '11 01:05

nambrot


3 Answers

Add the notify="true" attribute to the fb:comments tag.

<fb:comments notify="true" href='someurl' width='400'></fb:comments>
FB.Event.subscribe('comment.create', function(response)
{
 alert(response);
}
like image 89
Jannie Avatar answered Oct 17 '22 00:10

Jannie


why not to close the function call?

FB.Event.subscribe('comment.create', function(response)
{
  alert(response);
});

like image 4
Andrey Avatar answered Oct 17 '22 01:10

Andrey


I was having the same issues until I stumbled upon this answer here:

Methods subscribed via FB.Event.subscribe to comment.create or comment.remove are not triggered

You should put everything related to FB.[...] functions (FB.init, FB.Event.suscribe, ...) in

window.fbAsyncInit = function(){ // Your code });

Otherwise your code will be parsed before the FB js sdk has been fully loaded and you will >never really suscribe to your event

That might be obvious to a lot of people but for me and others who are new to this that might trip you up.

like image 1
Ranknoodle Avatar answered Oct 17 '22 00:10

Ranknoodle