使用Graph API v.2.0获取Facebook的朋友 [英] Get facebook friends with Graph API v.2.0

查看:163
本文介绍了使用Graph API v.2.0获取Facebook的朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前段时间,我曾经以这种方式(使用Graph API Explorer)使用Graph API来访问我的朋友:

  / me / friends 

一切都很完美,但现在,使用2.0版本,我看到这样对于没有使用(通过Facebook登录)的应用程序发出请求的朋友,如果我将Graph API Explorer切换到1.0版本,它将不起作用。



那么,我怎么能和2.0版本一样呢?

解决方案

在API的v2.0中, / me / friends 返回也登录了该应用的朋友。



2014年4月30日或之后创建的应用程序必须使用图形API v2.0;他们无法调用Graph API v1.0。



对于在4月30日以前有效的应用程序,这些应用程序可以调用Graph API v2.0或Graph API v1.0,但Graph API v1.0将于2015年4月30日弃用。



请注意,如果用户通过v2.0登录到应用程序,并且您调用 /v1.0/me/friends ,这仍然只会返回应用程式使用的朋友。



如果你想如果您想让用户将您发布到Facebook的故事中的人标记出来,您可以使用 / me / taggable_friends API访问非应用程式使用的朋友。



如果您想邀请其他人使用您的应用,游戏可以使用 / me / invitable_friends 端点以呈现自定义邀请选择器。此API返回的令牌可以在请求对话框中使用。请参阅 https://developers.facebook.com/docs/games/invitable- friends / v2.0 https://developers.facebook.com /docs/games/requests/v2.0



对于希望允许人们邀请朋友使用应用程序的非游戏,您仍然可以使用< a href =https://developers.facebook.com/docs/sharing/reference/send-dialog =noreferrer>在Web上发送对话框或 iOS Android


A while ago, I used to take the friends of mine using Graph API in this way (using Graph API Explorer):

/me/friends

Everything was perfect but now, with 2.0 version, I saw that this way does not function for friends who didn't use (via Facebook Login) the app making the request and, if I switch Graph API Explorer to 1.0 version, it functions.

So, how can I do the same thing with the 2.0 version?

解决方案

In v2.0 of the API, /me/friends returns friends who also have logged into the app.

Apps created on or after April 30th 2014 must use Graph API v2.0; they're not able to call Graph API v1.0.

For apps which were active before April 30th, these apps can call either Graph API v2.0 or Graph API v1.0, but Graph API v1.0 will be deprecated on April 30th 2015.

Note that if a user logs into an app via v2.0, and you call /v1.0/me/friends, this will still only return app-using friends.

If you want to access non-app-using friends in the case where you want to let your users tag people in stories you publish to Facebook, you can use the /me/taggable_friends API.

In the case where you want to invite people to use your app, Games can use the /me/invitable_friends endpoint in order to render a custom invite selector. The tokens returned by this API can then be used in the Requests Dialog. See https://developers.facebook.com/docs/games/invitable-friends/v2.0 and https://developers.facebook.com/docs/games/requests/v2.0

For non-games wanting allow people to invite friends to use an app, you can still use the Send Dialog on Web or the Message Dialog on iOS and Android

这篇关于使用Graph API v.2.0获取Facebook的朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆