Wesley Skeen
Wesley Skeen

Reputation: 8285

Notify a facebook user if a comment is made using the <fb:Comments> comment box

I have an application on facebook and i have the facebook comment box on it. If someone makes a comment using the comment box, is there a way to notify person that a post has been made on their app

I have the following code

<script src="https://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:comments xid="test" canpost="true" candelete="false" href="<%= link %>"  num_posts="10" width="500" send_notification_uid="<%= fbUserId %>" notify="true" publish_feed="true"></fb:comments>

The href - link is a dynamic link depending on where the post was made. The send_notification_uid - user_Id is also dynamic and it retrieves the user id of the person that owns the page.

Any help would be great. It all works apart from the send notification

Upvotes: 0

Views: 997

Answers (2)

Cyril N.
Cyril N.

Reputation: 39879

I don't know if the specs changed, but the current answer doesn't work anymore, the new way is now this :

FB.Event.subscribe('comment.create', function() {
    console.log('Comment was added');
    console.log(arguments);
});

comment.create , as explained here : https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v2.0#comments-example

Upvotes: 0

TommyBs
TommyBs

Reputation: 9646

I believe using the javascript SDK you can subscribe to the comment.create event. Then provided you have the necessary permissions for the uid in question, you could then send them a notification I believe. I haven't tested this but you need to look at the FB.event.subscribe code

https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

There's some more information on a post here

http://facebook.stackoverflow.com/questions/6146925/fb-event-subscribecomment-create-doesnt-work

Further to this you can test things out on the js skd tool

https://developers.facebook.com/tools/console/

and some sample code

<h1>Defaults</h1>
<fb:comments href="http://www.fbrell.com/"></fb:comments>

<script>
FB.Event.subscribe('comments.add', function(resp) {
console.log('Comment was added' + resp);
});
</script>

Upvotes: 1

Related Questions