php 获取 Facebook 帖子的所有分享列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11491908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get a list of all the shares of a facebook post
提问by Andrei
I can get a list of comments and likes just fine using the facebook sdk. But i can't find a way to get a list of all the users that shared a post (i tried fql as well).
我可以使用 facebook sdk 获得评论和喜欢的列表。但是我找不到获取共享帖子的所有用户列表的方法(我也尝试过 fql)。
This is the code i used to get the likes:
这是我用来获得喜欢的代码:
$facebook = new Facebook($config);
$likes = $facebook->api('/THE_POST_ID/likes',
array('limit'=>9999999999));
回答by sensimevanidus
At the time of writing this, Facebook Graph API allows you to get the count of shares of a post. Using your code, it would look like the following (please not that I'm not doing any exception handling here for keeping the example simple):
在撰写本文时,Facebook Graph API 允许您获取帖子的分享次数。使用您的代码,它看起来如下所示(请注意,我没有在这里做任何异常处理以保持示例简单):
$facebook = new Facebook($config);
// fetch the post data.
$post = $facebook->api('/THE_POST_ID/');
// fetch the count of shares.
$sharesCount = $post["shares"]["count"];
Using the Graph API Exploreryou can easily see that.
使用Graph API Explorer,您可以轻松地看到这一点。
Unfortunately, the API does not provide a "shares" connection like it does for "likes" and "comments". See Post - Facebook Graph API Documentationfor details.
不幸的是,API 没有像“喜欢”和“评论”那样提供“共享”连接。有关详细信息,请参阅Post - Facebook Graph API 文档。
On the other hand, there is a dirty hack for retrieving the list of users (only friends and people who shared publicly) who shared a specific post. The solution is explained on another thread: List of people who shared on facebook. But, I would never suggest using that solution.
另一方面,检索共享特定帖子的用户列表(仅限朋友和公开共享的人)有一个肮脏的黑客。另一个线程解释了该解决方案:在 facebook 上共享的人员列表。但是,我永远不会建议使用该解决方案。
回答by IRvanFauziE
Yes you can get list of all the shares of a facebook post.
是的,您可以获得 Facebook 帖子的所有共享列表。
by accessing:
通过访问:
https://graph.facebook.com/{POST_ID}/sharedposts?access_token={ACCESS_TOKEN}
See: https://developers.facebook.com/docs/graph-api/reference/v2.5/post
请参阅:https: //developers.facebook.com/docs/graph-api/reference/v2.5/post
回答by Brent M Clark
I know you're looking to get at shares through the post_id, but can you settle for finding shares by page_id instead of post_id?
我知道您希望通过 post_id 获取份额,但是您能否满足于通过 page_id 而不是 post_id 查找份额?
If you can, then you can use the following FQL to get the data you're looking for.
如果可以,那么您可以使用以下 FQL 来获取您要查找的数据。
SELECT via_id, created_time, owner_comment
FROM link
WHERE owner = me()
You can then compare via_id against the posts author (page ID) to determine if this share came from the post author in question.
然后,您可以将 via_id 与帖子作者(页面 ID)进行比较,以确定此共享是否来自相关帖子作者。
Unfortunately, there seems to be a bug with the data return where some of the via_ids come back as 0. There is a ticket in with Facebook which, at the time of this post, has been open for three weeks at medium priority. I have no idea if this issue is specific to my app or affects everyone, but that query might get you what you want.
不幸的是,数据返回似乎存在错误,其中一些 via_id 返回为 0。Facebook 有一张票,在本文发布时,该票已以中等优先级开放三周。我不知道这个问题是特定于我的应用程序还是影响到每个人,但该查询可能会满足您的需求。


