简体   繁体   English

通过图形API检索Facebook用户墙帖

[英]Retrieving facebook user wall posts through graph API

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 我正在开发一个Facebook应用程序,它捕获指定用户,页面或组的墙贴,在用户授权应用程序后我引用返回的access_token来调用方法

https://graph.facebook.com/ /feed?access_token= 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? 是否可以使用此方法获取所有帖子?

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. 是的,根据https://developers.facebook.com/docs/reference/api/permissions中列出的权限,呼叫结果因关系而异。

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. 由于一些奇怪的原因(通过Facebook的设计或遗漏)使用图形API来使用用户访问令牌获取公共帖子只是不想工作。

For example, You can see some public items here 例如,您可以在此处查看一些公共项目

http://www.facebook.com/zuck http://graph.facebook.com/zuck http://www.facebook.com/zuck http://graph.facebook.com/zuck

However, you cannot seem to get any feed from here without an access token 但是,如果没有访问令牌,您似乎无法从此处获取任何Feed

https://graph.facebook.com/zuck/feed https://graph.facebook.com/zuck/feed

{
   "error": {
      "message": "An access token is required to request this resource.",
      "type": "OAuthException"
   }
}

Let's try adding an user access token that does not belong to zuck or a friend of zuck. 让我们尝试添加一个不属于zuck或zuck的朋友的用户访问令牌。 https://graph.facebook.com/zuck/feed?access_token= {UserAccessToken} https://graph.facebook.com/zuck/feed?access_token= {UserAccessToken}

And here's what we get: 这就是我们得到的:

{
   "data": [

   ]
}

What about an app access token? 应用访问令牌怎么样? Let's try https://graph.facebook.com/zuck/feed?access_token= {AppAccessToken} 我们来试试https://graph.facebook.com/zuck/feed?access_token= {AppAccessToken}

{
   "error": {
      "message": "Invalid OAuth access token signature.",
      "type": "OAuthException"
   }
}

So as you can see, it's difficult to get things via the graph that are not in alignment with your access token. 正如您所看到的,通过图表获取与您的访问令牌不一致的内容很困难。

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). 例如,您必须添加“ read_stream ”和“ user_status ”(我发现这些是生成正确访问令牌的最重要的权限“密钥”,以检索一个所谓的“公共”提要)。

You can add more into generating the access token, in either you want the permission to GET, or POST, or BOTH. 您可以在生成访问令牌时添加更多内容,您可以获得GET,POST或BOTH的权限。

Source is here: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog 来源在这里: 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. 我发现的一件事是,从用户的“主页/关于”页面获取提要结果的方式和Facebook页面(为人们喜欢(不添加朋友)而创建)是不同的。 The key is mentioned above, " read_stream ", and " user_status ". 上面提到了密钥“ read_stream ”和“ 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. 因此,最好添加两个权限,以便生成访问令牌以获取Feed中的所有内容。

Graph API doesn't return posts to the App if is not authorized to read user feed, even if posts are public. 如果未授权读取用户订阅源,即使帖子是公开的,图谱API也不会将帖子返回给应用。

Source: https://developers.facebook.com/bugs/290004301178437/ 资料来源: https//developers.facebook.com/bugs/290004301178437/

According to the latest api , 根据最新的api,

FB.api("/me/feed","get",function(response) {//callback})

should do and also work well . 应该做的也很好。 It is working now but facebook may change it in future. 它现在正在运行,但Facebook将来可能会改变它。

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

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