简体   繁体   English

通过Graph API而不是Comments插件在您的网站上使用Facebook Comments?

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

Facebook offers the Comments Plugin for adding comments to any website: Facebook提供了用于将评论添加到任何网站的评论插件:

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

Is it possible to GET and POST comments to your website via the Graph API? 是否可以通过Graph API获取和发布评论到您的网站?

My "URL to comment on" is http://www.examplesite.com/test/ . 我的“要评论的网址”是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: 如果我使用上述评论插件将评论添加到我的网站,则可以通过以下URL访问所有评论:

https://graph.facebook.com/comments/?id=http://www.examplesite.com/test 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? 现在,是否有一种方法可以通过Graph API对此进行POST和GET评论? I assume my "post id" is http://www.examplesite.com/test . 我假设我的“帖子ID”是http://www.examplesite.com/test I'm trying to use the PHP SDK like so: 我试图像这样使用PHP SDK:

$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? 还是无法通过API向您的网站添加评论?

Dunno about the comment post. Dunno关于评论文章。 but you can get the comments as an assoc array via the API as follows: 但是您可以通过API以assoc数组的形式获取注释,如下所示:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM