问题描述:

I have a website where there is comments systems. I want to add a comment to facebook while adding a comment to my website.

If it is not possible to add to Facebook while adding to my site is it possible to show share to facebook button with each comments so that clicking on it will share that comment on facebook. May be possible with fb.in?

网友答案:

Not 100% sure, but it sounds like you have your own comment system on your web site and that you'd like to auto-publish to FB the comment that someone makes on your own site.

You'd need to implement the Facebook SDK on your web site:

  1. Have your user authorize your site using 'FB.login' with 'publish_stream' permission (see docs).
  2. In your comment system code, after your user has entered in their comment, you can make a separate call to the Graph API to publish to the user's feed. For example, if using the Facebook Javascript SDK:

Following is the code:

var body = myJustEnteredComment;

FB.api('/me/feed', 'post', { message: body }, function(response)
{
    if (!response || response.error)
    {
        alert('Error!');
    } 
});
相关阅读:
Top