Facebook Comments on your website via Graph API instead of Comments plugin?

╄→гoц情女王★ 提交于 2019-12-08 05:38:40

问题


Facebook offers the Comments Plugin for adding comments to any website:

https://developers.facebook.com/docs/reference/plugins/comments/

Is it possible to GET and POST comments to your website via the Graph API?

My "URL to comment on" is http://www.examplesite.com/test/. If I use the above comments plugin to add a comment to my site, I can access all the comments at the following URL:

https://graph.facebook.com/comments/?id=http://www.examplesite.com/test

Now, is there a way to POST and GET comments to this via the Graph API? I assume my "post id" is http://www.examplesite.com/test. I'm trying to use the PHP SDK like so:

$params = array( 'message' => 'Hello World!!' );
$facebook->api("http://www.examplesite.com/test/comments", "POST", $params);

Also tried to fetch comments as well:

$comments = $facebook->api("http://www.examplesite.com/test/comments", "GET");

No dice with either of those. Can't post comments or fetch comments.

Am I doing something wrong? Or is it not possible to add comments to your site via the API?


回答1:


Dunno about the comment post. but you can get the comments as an assoc array via the API as follows:

    $url = 'http://test.com';
    $arr = $this->facebook->api('comments/?ids='.$url); 

    echo("<pre>");
    print_r($arr[$url]['comments']['data']); 


来源:https://stackoverflow.com/questions/10546362/facebook-comments-on-your-website-via-graph-api-instead-of-comments-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!