In Facebook Graph API, what are the API calls to get a user's email address and gender?

后端 未结 1 1305
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-26 02:27

I\'m using the Graph API and the Facebook SDK for PHP with the help of this link: https://developers.facebook.com/docs/php/howto/profilewithgraphapi/4.0.0. This is the code:

相关标签:
1条回答
  • 2021-01-26 02:58

    Have a look at

    • https://developers.facebook.com/docs/graph-api/reference/v2.2/user#fields
    • https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#fields

    to get an overview what fields and edges you can query for the user object. In your case, that should be

    /me?fields=id,gender,email
    

    or

    new FacebookRequest(
      $session, 'GET', '/me?fields=id,gender,email'
    )
    

    Be aware that you'll need the user_email permission to be able to request the email field.

    To get specific fields, use the getProperty() method as described at https://developers.facebook.com/docs/php/GraphObject/#getproperty

    echo $user_profile->getProperty('gender');
    
    0 讨论(0)
提交回复
热议问题