Facebook JS SDK's FB.api('/me') method doesn't return the fields i expect in Graph API v2.4+

后端 未结 4 2119
有刺的猬
有刺的猬 2020-11-21 05:38

I\'m trying to get some basic information using Facebook api, but so far I only get the user\'s name and id. As in { name: \"Juan Fuentes\", id: \"123456\" }

4条回答
  •  不知归路
    2020-11-21 06:34

    You need to manually specify each field since Graph API v2.4:

    • https://developers.facebook.com/docs/apps/changelog#v2_4
    • https://developers.facebook.com/docs/javascript/reference/FB.api

    Declarative Fields
    To try to improve performance on mobile networks, Nodes and Edges in v2.4 requires that you explicitly request the field(s) you need for your GET requests. For example, GET /v2.4/me/feed no longer includes likes and comments by default, but GET /v2.4/me/feed?fields=comments,likes will return the data. For more details see the docs on how to request specific fields.

    E.g.

    FB.api('/me', 'get', { access_token: token, fields: 'id,name,gender' }, function(response) {
        console.log(response);
    });
    

提交回复
热议问题