问题
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