如何使用 php SDK 检索 Facebook 帖子上的所有评论?
我正在构建一个应用程序,允许用户将文章发布到他们的 Facebook 墙上。发布文章后,我会检索帖子 ID 并将其与文章的其余详细信息一起存储在数据库中。现在,当有人在我的网站上查看该文章时,我希望能够显示对该帖子的评论;我还希望允许用户从我的网站向帖子添加评论。
我知道用户在查看文章时始终会登录 Facebook,因为系统会提前进行检查。
我一直在使用 PHP SDK,并且认为我所要做的就是:
$post_comments = $facebook->api('/' . $post_id . '/comments');
但是,当我这样做时,我收到以下错误:
致命错误:未捕获的 GraphMethodException:不支持的 get 请求。在第 560 行抛出 /APP_PATH/facebook/src/facebook.php
说实话,我真的不知道我在这里做什么,因为我对 Facebook Graph API 非常陌生,而且我似乎找不到很多关于它的文档。
谁能告诉我我应该在这里做什么,或者向我指出一些我可以阅读的文档?
谢谢!
I'm building an app which allows users to post articles to their facebook wall. When an article is posted, I retrieve the post id and store that in the database along with the rest of the article details. Now I want to be able to show the comments made on that post when someone views the article in my site; I would also like to allow users to add comments to the post from my site.
I know that the user is always logged into Facebook when they are viewing the article, as the system checks for that earlier on.
I've been using the PHP SDK, and thought all I had to do was something like:
$post_comments = $facebook->api('/' . $post_id . '/comments');
However, when I do this, I get the following error:
Fatal error: Uncaught GraphMethodException: Unsupported get request. thrown in /APP_PATH/facebook/src/facebook.php on line 560
I really don't have much of a clue what I'm doing here, to be honest, as I'm very new to the Facebook Graph API, and I can't seem to find a lot of documentation on it.
Can anyone tell me what I should be doing here, or point me to some documentation I could read about it?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它应该有效。
这是我正在使用的对我有用的代码。
确保您的
postid
有效。或者,您可以直接在浏览器中输入该网址以获取如下详细信息
https://graph.facebook.com//comments
请参阅此链接以获取更多参考
http://developers.facebook.com/docs/reference/api/Comment/
It should work.
Here is the code I am using which is working for me.
Make sure your
postid
is a valid one.Alternatively, you can directly type that url in browser to get details like this
https://graph.facebook.com/<postedid>/comments
Please refer this link for further reference
http://developers.facebook.com/docs/reference/api/Comment/
我不知道您的 PHP 库在做什么,但您实际上可以通过阅读
graph.facebook.com//comments
来访问评论。事实上,请尝试使用文档中的这个。您确定您的帖子 ID 吗?尝试使用
19292868552_118464504835613
作为帖子 ID 来调用 buggy 函数。它必须发挥作用。I don't know what your PHP library is doing, but you can actually access comments by reading
graph.facebook.com/<post_id>/comments
. Indeed, try with this one from the doc.Are your sure of your post id? Try to call the buggy function with
19292868552_118464504835613
as post id. It has to work.