问题描述
Facebook提供了用于将评论添加到任何网站的评论插件:
Facebook offers the Comments Plugin for adding comments to any website:
https://developers.facebook.com/docs/reference/plugins/comments /
是否可以通过Graph API获取和发布评论到您的网站?
Is it possible to GET and POST comments to your website via the Graph API?
我的要评论的网址"是http://www.examplesite.com/test/
.如果我使用上述评论插件将评论添加到我的网站,则可以通过以下URL访问所有评论:
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
现在,有没有一种方法可以通过Graph API对此进行POST和GET注释?我假设我的帖子ID"为http://www.examplesite.com/test
.我正在尝试像这样使用PHP SDK:
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);
还尝试获取评论:
$comments = $facebook->api("http://www.examplesite.com/test/comments", "GET");
任何一个都没有骰子.无法发表评论或获取评论.
No dice with either of those. Can't post comments or fetch comments.
我做错什么了吗?还是无法通过API向您的网站添加评论?
Am I doing something wrong? Or is it not possible to add comments to your site via the API?
推荐答案
Dunno.但是您可以通过API以assoc数组的形式获取注释,如下所示:
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']);
这篇关于通过Graph API而不是Comments插件在您的网站上添加Facebook Comments?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!