简体   繁体   English

Facebook的SDK PHP的获得朋友的名字

[英]facebook sdk php get friends names

我已经读过有关php的新facebook sdk的信息,它说您无法再检索朋友信息,并且它说的是邀请朋友等。但是实际上我使用的应用程序会获得一些随机的朋友姓名,但并不是一个游戏应用程序,我需要完全相同的,随机的朋友姓名,问候。

There is a new API endpoint that can be used to get friend names. 有一个新的API端点,可用于获取朋友名称。 The new /me/taggable_friends friends API call is what you can use: 您可以使用新的/me/taggable_friends friends API调用:

/v2.0/me/taggable_friends

The response will include friend names, profile picture and an encrypted ID that can be used with tagging API calls. 响应将包括朋友名称,个人资料图片和可用于标记API调用的加密ID。 See the documentation here . 请参阅此处的文档

Using the JS API, you can do something like: 使用JS API,您可以执行以下操作:

FB.login(function(){
  FB.api('/me/taggable_friends', 'get', function( response ) {
    console.log( response );
  } );
} );

Using PHP: 使用PHP:

$taggable = (new FacebookRequest( $session, 'GET', '/me/taggable_friends' ))->execute()->getGraphObject()->asArray();
echo '<pre>' . print_r( $taggable, 1 ) . '</pre>';

See the full PHP example here . 在此处查看完整的PHP示例

You have to get this permission reviewed to use it with end-users. 您必须先审查此权限才能与最终用户一起使用。 If you don't, you'll see a message like: 否则,您会看到类似以下的消息:

(#10) To use taggable_friends on behalf of people who are not admins, developers and testers of your app, your use of this endpoint must be reviewed and approved by Facebook. (#10)要代表不是您应用程序的管理员,开发人员和测试人员的人员使用taggable_friends,您对此端点的使用必须经过Facebook的审查和批准。 To submit this feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review 要提交此功能以供审核,请阅读我们有关可审核功能的文档: https : //developers.facebook.com/docs/apps/review


EDIT 编辑

To get larger profile images for friends, you need to use the fields parameter and request a specific type or size of image, eg: 要为朋友获取更大的个人资料图像,您需要使用fields参数并请求特定类型或尺寸的图像,例如:

/me/taggable_friends?fields=id,name,picture.type(large)

OR 要么

/me/taggable_friends?fields=id,name,picture.width(500)

Using PHP: 使用PHP:

$taggable = (new FacebookRequest( $session, 'GET', '/me/taggable_friends', [ 'fields' => 'id,name,picture.type(large)' ] ))->execute()->getGraphObject()->asArray();
echo '<pre>' . print_r( $taggable, 1 ) . '</pre>';

From v2.0 onwards; 从v2.0开始; only the friends using the app that is requesting can be fetched with {user-id}/friends . 只有使用请求的应用程序的朋友才能与{user-id}/friends

Using the same API with v1.0 was able to fetch all the friends list. 在v1.0中使用相同的API可以提取所有好友列表。 But this version will be removed after April 30, 2015. Reference 但是,此版本将于2015年4月30日之后删除。 参考

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

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