如何使用 php SDK 检索 Facebook 帖子上的所有评论?

发布于 2024-10-31 08:50:27 字数 565 浏览 0 评论 0原文

我正在构建一个应用程序,允许用户将文章发布到他们的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

℉服软 2024-11-07 08:50:27

它应该有效。

这是我正在使用的对我有用的代码。

$comments = $facebook->api($postid . '/comments');

确保您的 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.

$comments = $facebook->api($postid . '/comments');

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/

只是一片海 2024-11-07 08:50:27

我不知道您的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文