我使用facebook sdk api和symfony,在下面的$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
)电子邮件和生日为空。
发布于 2012-09-03 00:09:23
在您的代码中,似乎没有请求访问用户的电子邮件地址或生日所需的Permission
检查权限文档,确保在Authentication代码中请求email和user_birthday权限。
发布于 2012-09-02 21:21:09
如果你没有收到这些信息,其中一个原因是因为用户配置禁止分享它们,Facebook没有发送警告。
因为某些用户在配置中禁止共享电子邮件或其他信息。
发布于 2012-09-03 14:52:14
我搜索了如何在代码中编写,然后我发现我必须在登录url的作用域内请求电子邮件权限:
$params = array(
'redirect_uri' => url_for('sfGuardAuth/loginWithFB', true),'scope' => 'email,user_birthday,user_location'
);
$loginUrl = $facebook->getLoginUrl($params);https://stackoverflow.com/questions/12236232
复制相似问题