通过Graph API检索Facebook用户墙帖子
我目前正在开发一个 Facebook 应用程序,它捕获指定用户、页面或组的墙帖,在用户授权该应用程序后,我引用返回的 access_token 来调用方法
https://graph.facebook.com//feed?access_token=
这对于页面和组来说效果很好,因为我们只需要一个有效的令牌,但是对于用户来说根据授权用户之间的关系,结果会有所不同应用程序正在捕获其帖子的用户。
例如,如果两个用户之间没有关系,则某些帖子不会返回,即使它们是公开的并且在您查看用户的个人资料时显示,但如果他们是朋友,则会返回更多帖子。
有人可以解释一下这种行为吗?使用这种方法可以获取所有帖子吗?
I'm currently working on a facebook app which captures wall posts for a specified user, page or group, after a user has authorized the app I quote the access_token that is returned to call the method
https://graph.facebook.com//feed?access_token=
this works fine for pages and groups as we only need a valid token, however for users the results are different depending on the relationship between the user who authorized the app the user whose posts are being captured.
For example if there is no relationship between the two users some posts are not returned even though they are public and displayed when you view the profile of the user, however if they are friends more posts are returned.
Can someone please explain this behaviour? And is it possible to obtain all posts using this method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,根据 https://developers.facebook.com/docs/reference/ 中列出的权限api/permissions 根据关系的不同,调用的结果也不同。
但是,当事物是公开的并且您使用不属于用户的访问令牌时,则不会返回任何结果。我不记得什么时候不是这样的。由于某些奇怪的原因(Facebook 的设计或遗漏),使用图形 API 使用用户访问令牌获取公共帖子是行不通的。
例如,您可以在此处查看一些公共项目
http://www.facebook.com/zuck
http://graph.facebook.com/zuck
但是,如果没有的话,您似乎无法从这里获得任何提要访问令牌
https://graph.facebook.com/zuck/feed
让我们尝试添加用户不属于 zuck 或 zuck 的朋友的访问令牌。 https://graph.facebook.com/zuck/feed?access_token={UserAccessToken这
就是我们得到的:
应用程序访问令牌怎么样?让我们尝试一下
https://graph.facebook.com/zuck/feed?access_token={AppAccessToken正如
您所看到的,很难通过图表获取与您的访问令牌不符的内容。
Yes, per the permissions listed at https://developers.facebook.com/docs/reference/api/permissions the results of the call are different depending upon the relationship.
However when things are public and you use an access token that doesn't belong to the user, then no results are returned. I cannot remember a time when this wasn't this way. For some odd reason (by design or omission on Facebook's part) using the graph API to get at public posts using a user access token just doesn't want to work.
For example, You can see some public items here
http://www.facebook.com/zuck
http://graph.facebook.com/zuck
However, you cannot seem to get any feed from here without an access token
https://graph.facebook.com/zuck/feed
Let's try adding an user access token that does not belong to zuck or a friend of zuck. https://graph.facebook.com/zuck/feed?access_token={UserAccessToken}
And here's what we get:
What about an app access token? Let's try
https://graph.facebook.com/zuck/feed?access_token={AppAccessToken}
So as you can see, it's difficult to get things via the graph that are not in alignment with your access token.
我设法从用户的墙上帖子中获取大部分提要。虽然这是一篇旧帖子,但我希望有人能从我的回答中得到他们想要的东西。
在获取访问令牌(以获取提要)之前,您需要添加多个正确的读取权限“密钥”。
例如,您必须添加“read_stream”和“user_status”(我发现这些是生成正确访问令牌的最重要的权限“密钥” ,检索所谓的“公共”提要)。
您可以在生成访问令牌时添加更多内容,无论您想要 GET、POST 或两者的权限。
来源在这里: https://developers.facebook.com/docs/howtos/ ios-6/#nativeauthdialog
我发现的一件事是,从用户的“主页/关于”页面和 Facebook 页面(为人们喜欢(而不是添加朋友)而创建)获取提要结果的方法是 不同的。上面提到了键“read_stream”和“user_status”。因此,最好添加这两个权限,以便生成访问令牌以获取源中的所有内容。
I manage to get most of the feeds from user's wall post. Although this is a old post, I hope someone can manage to get what they want from my answer.
Before getting the access token(to get the feeds), you need to add multiple correct Read Permissions "keys".
For example, you will have to add "read_stream", and "user_status" (which I found that these are the most important permission "key" to generate the correct access token, to retrieve one's so-called "public" feeds).
You can add more into generating the access token, in either you want the permission to GET, or POST, or BOTH.
Source is here: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog
One thing that I found is, the way to get the feeds result from user's "Home/About" page and Facebook Page (which is created for people to like (not add friends)) are different. The key is mentioned above, "read_stream", and "user_status". So it's better that you add both of the permissions in order to generate the access token to get everything in feeds.
如果无权读取用户源,即使帖子是公开的,Graph API 也不会将帖子返回到应用程序。
来源:https://developers.facebook.com/bugs/290004301178437/
Graph API doesn't return posts to the App if is not authorized to read user feed, even if posts are public.
Source: https://developers.facebook.com/bugs/290004301178437/
根据最新的api,
应该可以并且工作得很好。
它现在正在运行,但 Facebook 将来可能会改变它。
According to the latest api ,
should do and also work well .
It is working now but facebook may change it in future.