简体   繁体   English

使用javascript获取Facebook用户的朋友

[英]fetch facebook user's friends with javascript

I am a new comer of StackOverFlow. 我是StackOverFlow的新手。 As title, I 'd like to pick a subset of the user's friends, and I have tried that in the Graph API Explorer with → /v2.1/ me?fields=friends . 作为标题,我想选择一部分用户的朋友,我已经在Graph API Explorer中使用→ /v2.1/ me?fields=friends进行了尝试。 However it return an empty json named data and the total count of the user's friends. 但是,它将返回一个空的名为data的json和用户朋友的总数。 What did I miss?? 我错过了什么?? Below is my test in the facebook Graph API explorer.. ! 以下是我在facebook Graph API资源管理器中的测试。 Here comes the result in the graph api explorer. 图api资源管理器中的结果如下。

{
    "friends": {
        "data": [
            ], 
        "summary": {
          "total_count": 15
        }
        }, 
    "id": "585768444863088"
}

You can also just use /me/friends instead, but the empty array is correct. 您也可以只使用/me/friends ,但是空数组是正确的。 You only get those friends who authorized your App too, you don´t get every friend anymore since end of April 2014 (v2.0 of the Graph API). 您也只会获得授权您的应用程序的那些朋友,自2014年4月(Graph API v2.0)以来,您再也没有得到任何朋友。

See here: https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids 看到这里: https : //developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids

  1. /me/friends returns the user's friends who are also using your app / me / friends返回也在使用您的应用程序的用户朋友

There are ways to get the whole friendlist like invitable_friends and https://developers.facebook.com/docs/graph-api/reference/v2.1/user/taggable_friends , but those endpoints are supposed to get used for very specific tasks (for inviting in games and for tagging). 有多种方法可以获取整个好友列表,例如invitable_friendshttps://developers.facebook.com/docs/graph-api/reference/v2.1/user/taggable_friends ,但是这些端点应该用于非常具体的任务(用于游戏邀请和标记)。

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

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