【问题标题】:Facebook Graph API - get friends infoFacebook Graph API - 获取好友信息
【发布时间】:2011-04-01 17:15:28
【问题描述】:

我正在尝试弄清楚如何使用 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 而不是数组。那个朋友肯定有工作经历。

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

【问题讨论】:

    标签: facebook facebook-graph-api


    【解决方案1】:

    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
    

    希望对你有帮助:)

    【讨论】:

      【解决方案2】:

      我自己整天都在为此苦苦挣扎,我相信我已经弄清楚了,在 facebook 文档(我发现)中没有任何地方这么清楚。而且我不相信其他答案实际上回答了您的问题,看起来您正确请求了权限。无论如何,要请求您要查找的信息,请像这样 ping api:

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

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

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

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

      【讨论】:

      • 非常感谢您提供的信息,正是我想要的
      【解决方案3】:

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

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

      在链接中提到了在获取信息之前要获得什么权限以及用户必须允许您的应用程序的另一件事,这将使您的应用程序获取信息。

      【讨论】:

        【解决方案4】:

        this answeranother question:对“me/friends?fields=work”的调用对我有用!

        【讨论】:

        • 嗨@Gustavo Ambrozio,我正在做这个'me/friends?fields=education'& 获取所有详细信息,但我想要你所有的朋友在我学习的同一所学校/大学学习。有可能吗?
        【解决方案5】:

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

        P.S:应编辑的原始问题中有轻微的拼写错误。 “教育历史。” = 教育历史 在主要段落的第二行。

        【讨论】:

          【解决方案6】:

          您可以使用此代码获取您朋友的姓名、头像、ID。

          FB.api('/me/taggable_friends', function(response) { for (var i = 0; i

          在此之前在您的开发者帐户中创建应用程序-> 转到工具和支持-> 图形 API 资源管理器-> 单击获取令牌。在该窗口中单击 user_tagged_places 并单击获取访问令牌。你会得到你的朋友列表。

          【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-01-19
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多