dongtuojuan8998 2014-12-01 02:22
浏览 167
已采纳

在Facebook Graph API中,获取用户电子邮件地址和性别的API调用是什么?

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:

use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;

if($session) {

  try {

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

    echo "Name: " . $user_profile->getName();

  } catch(FacebookRequestException $e) {

    echo "Exception occured, code: " . $e->getCode();
    echo " with message: " . $e->getMessage();

  }   

}

I'm at the point where I'm able to get a user's name by using user_profile->getName();, I can also get his/her first name, last name, middle name, etc., according to the API calls here: https://developers.facebook.com/docs/php/GraphObject/#user-instance-methods. I know it is possible to get a user's email address and gender, but in the previous link I didn't find any API calls to be able to get this information.

For Facebook SDK for PHP, what are the API calls to get a user's email address and gender?

Thank you very much.

  • 写回答

1条回答 默认 最新

报告相同问题?