Facebook Graph API - 获取好友信息

发布于 2024-10-29 01:15:50 字数 1320 浏览 2 评论 0原文

我正在尝试弄清楚如何使用 Graph API 或 FQL 获取用户朋友信息

只是为了测试我想获取我的朋友 education_histroy

为此,我创建了一个测试应用程序,请求使用扩展权限

scope=offline_access,manage_friendlists,friends_work_history,
      friends_education_history,friends_about_me

并获取访问令牌来使用 API。

当我使用 /me 查询当前用户时,它效果很好。但它没有给我的朋友带来任何回报。

我假设如果我请求,比如说 friends_work_history,当我通过朋友的 id 查询时,额外的字段 (work_history) 将出现在朋友的对象中:

https://graph.facebook.com/FRIEND_ID&access_token=TOKEN

但我看到的只是有关该信息的基本信息用户(朋友)。

然后我尝试专门请求该字段:

https://graph.facebook.com/ FRIEND_ID?fields=work&access_token=TOKEN

再次没有运气。仅返回朋友的 ID..

我尝试使用 FQL 访问该信息:

https://api.facebook.com/method/fql.query?query=select+work_history+from+user+where+uid+in+(FRIEND_ID) &access_token=TOKEN

返回 work_history = TRUE 而不是数组。而且那个朋友肯定有指定的工作经历。

有人可以帮助我了解如何使用我的应用程序和扩展权限获取朋友信息吗?

I'm trying to figure out how to get users friends information using either Graph API or FQL

Just for testing I would like to get my friends education_histroy.

To do that I created a test app, requested extended permissions using

scope=offline_access,manage_friendlists,friends_work_history,
      friends_education_history,friends_about_me

and got access token to play with the API.

It works great when I query for current user using /me. But it returns nothing for my friends.

I was assuming that if I request, let's say friends_work_history, that extra field (work_history) will appear inside friend's object, when I query by friend's id:

https://graph.facebook.com/FRIEND_ID&access_token=TOKEN

But all I see is basic info about that user (friend).

Then I tried to request that field specifically:

https://graph.facebook.com/FRIEND_ID?fields=work&access_token=TOKEN

With no luck again. Returns just friend's id..

I tried to access that information with FQL:

https://api.facebook.com/method/fql.query?query=select+work_history+from+user+where+uid+in+(FRIEND_ID)&access_token=TOKEN

Returns work_history = TRUE instead of array. And that friend definitely has work history specified.

Can someone help me to understand how to get friends info using my app and extended permissions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(6

回忆追雨的时光 2024-11-05 01:15:50

在大多数情况下,Graph API 是明智的选择。要检索您的朋友信息,您需要首先从用户那里收集一些扩展权限。然后你可以检索除基本信息之外的更多信息。

以下是与朋友不同类型信息相关的扩展权限列表

friends_about_me        
friends_activities      
friends_birthday
friends_checkins        
friends_education_history       
friends_events
friends_games_activity      
friends_groups      
friends_hometown
friends_interests       
friends_likes       
friends_location
friends_notes       
friends_online_presence     
friends_photo_video_tags 
friends_photos      
friends_relationship_details        
friends_relationships
friends_religion_politics       
friends_status      
friends_subscriptions
friends_videos      
friends_website     
friends_work_history

希望它有所帮助:)

Graph API is the smart choice in most cases. To retrieve your friend information you need to collect some extended permissions from the user first. Then you can retrieve a lot more information other than the basic ones.

Following is a list of extended permissions related to friends different kind of information

friends_about_me        
friends_activities      
friends_birthday
friends_checkins        
friends_education_history       
friends_events
friends_games_activity      
friends_groups      
friends_hometown
friends_interests       
friends_likes       
friends_location
friends_notes       
friends_online_presence     
friends_photo_video_tags 
friends_photos      
friends_relationship_details        
friends_relationships
friends_religion_politics       
friends_status      
friends_subscriptions
friends_videos      
friends_website     
friends_work_history

Hope it helps :)

淡淡绿茶香 2024-11-05 01:15:50

我自己一整天都在努力解决这个问题,我相信我已经弄清楚了,Facebook 文档(我发现)中没有这么清楚的。而且我不相信其他答案实际上回答了您的问题,看起来您正确地请求了权限。不管怎样,要请求您正在寻找的信息,请像这样 ping api:

https://graph.facebook.com/userid/friends?fields=work&access_token=ACCESSTOKENHERE

这将在一个长 JSON 响应中返回您所有朋友的信息。

这有点令人困惑,因为您请求的权限与查询 API 所需的权限不同。

上面的查询将返回好友的 ID 和工作历史记录。您可以向 fields 参数添加逗号以包含名称等附加信息,但 API 调用/响应最终会花费很长时间。

I've been wrestling with this all day myself and I believe I have figured it out, nowhere in facebook documentation (that I have found) is this clear. And I don't believe the other answers actually answered your question, it looks like you requested permissions correctly. Anyway, to request the information you are looking for, ping the api like this:

https://graph.facebook.com/userid/friends?fields=work&access_token=ACCESSTOKENHERE

This will return you all the friends' info in one long JSON response.

It is a little confusing because the permissions you are asking for are not the same thing you need to query the API.

The query above will return the friends' ids with work history. You can add commas to the fields parameter to include additional info like name, but then the API calls/responses end up taking a long time.

Oo萌小芽oO 2024-11-05 01:15:50

http://developers.facebook.com/docs/reference/api/user/

您可以获取此处提到的所有字段。要获得工作,您需要拥有 user_work_history 或 friends_work_history 权限

链接中提到了在获取信息之前需要获取哪些权限以及用户拥有的其他内容允许您的应用程序,这将使您的应用程序获取信息。

http://developers.facebook.com/docs/reference/api/user/

you can get all the fields mentioned here .To get work you need to have user_work_history or friends_work_history permission

in the link it is mentioned what permissions to obtain before you get the info and another thing that user has to allow your application,this will make your app to get the informations.

不疑不惑不回忆 2024-11-05 01:15:50

这个答案另一个问题:对“me/friends?fields=work”的调用对我有用!

From this answer to another question: a call to 'me/friends?fields=work' worked for me!

风吹雨成花 2024-11-05 01:15:50

我建议您访问 http://developers.facebook.com/docs/像大多数其他人建议的那样,参考/api/user/,但作为一般提示,请使用friends_education_history作为获取好友历史记录的方式。

PS:您的原始问题中存在小拼写错误,应进行编辑。 “教育历史。” = 教育史
在主要段落的第二行。

I'd suggest that you go to http://developers.facebook.com/docs/reference/api/user/ like most of the others are suggesting but as a general tip, use the friends_education_history as a way to get the friend's history.

P.S: Minor spelling error in your original question that should be edited. "education_histroy." = education_history
in the second line of your main paragraph.

别理我 2024-11-05 01:15:50

您可以使用此代码获得您朋友的姓名、个人资料图片、ID。

FB.api('/me/taggable_friends', 函数(响应) {
for (var i = 0; i

在此之前,在您的开发者帐户中创建了应用程序->转到工具和支持->图形 API 浏览器->单击获取令牌。在该窗口中,单击 user_tagged_places,然后单击获取访问令牌。您将获得您的好友列表。

You can use this code you will get name, profile picture, ID of your friends.

FB.api('/me/taggable_friends', function(response) {
for (var i = 0; i < friend_data.length; i++) {
results += ''+friend_data[i].name;
}
});

Before that in your developer account created app-> go to tools and support->graph API explorer-> click Get Token. In that window click user_tagged_places and click Get Access Token. You will get your friends list.

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