我使用facebook sdk api和symfony,在$ user_profile數組中,他可以檢索除電子郵件和生日以外的所有信息。facebook api不檢索電子郵件和生日
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
)
電子郵件和生日空。
是從一些用戶檢索電子郵件,但其他一些用戶不 –