我使用带有 symfony 的 facebook sdk api,在下面的 $user_profile 数组中,他可以检索除电子邮件和生日之外的所有信息。
require 'facebook.php';
$app_id = sfConfig::get('app_facebook_app_id');
$app_secret = sfConfig::get('app_facebook_secret_key');
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$location= $user_profile['location']['name'];
$gender = $user_profile['gender'];
$user_info = array(
'uid' => $user_profile['id'],
'first_name' => $user_profile['first_name'],
'last_name' => $user_profile['last_name'],
'email' => $user_profile['email'],
'birthday' => $user_profile['birthday'],
'gender' => $user_profile['gender'],
);
当我使用print_r($user_profile)
它时返回:
Array (
[uid] => 100004246655890
[first_name] => Ala
[last_name] => Hamad
[email] =>
[birthday] =>
[gender] => male
)
电子邮件和生日为空。