检索同一个应用程序的好友列表facebook SDK 4.0(id,name,score ..)

时间:2015-02-17 10:36:09

标签: php facebook sdk

我正在寻找使用相同应用程序(PHP SDK 4)的所有朋友,使用uid,用户名和分数

我拥有此应用的权限:

('email','user_about_me','user_friends','publish_actions', 'user_games_activity')

现在,我正在使用这个脚本,它只检索使用同一个应用程序的用户的uid:

$me = (new \Facebook\FacebookRequest($session, 'GET', '/me/friends'))->execute()->getGraphObject(\Facebook\GraphUser::className());

$result = $me->asArray();

// Get user's friends

$friends = $result['data'];

// Converting classes to array

foreach ($friends as $key => $value) {
    $friends[$key] = (array)$value;
     echo $friends[0]['id']; //show the id of the user 0
    echo "|";       
}

我有一个问题只是检查所有朋友,我尝试更改此脚本,但我不能得到所有朋友,但只是第一个... [0]

现在,我搜索了很多关于这个话题的内容......但是我发现只是旧的SDK,有一个新的,我应该做什么来检索同一个应用程序的uid,用户名和分数?像这样:

         echo $friends[0]['id']; //show the id of the user 0
        echo "|";   
         echo $friends[0]['name']; //show the name of the user 0
        echo "|";   
         echo $friends[0]['score']; //show the score of the user 0
        echo "|";   

[number_uid0] | [nameusername0] | [得分0] | [number_uid1] | [nameusername1] | [得分1]等....

非常感谢:)

1 个答案:

答案 0 :(得分:0)

您不能再获得所有朋友,只有那些也会使用您的应用的朋友。并且所有friends_*权限都已删除,因此您无法简单地检索您的朋友'分数...

但是看看这里找到解决方案(我认为是)你的问题:

  

您可以通过向该应用的用户access_token发出带有/APP_ID/scores的HTTP GET请求来阅读播放器及其朋友的分数集。需要user_friends权限才能查看朋友'分数。这将返回已授权该应用的玩家和朋友的分数列表。列表按降序分数值排序,因此它首先返回分数最高的朋友。您可以使用此调用为玩家和朋友生成排行榜。