1

私は 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 
)

メールと誕生日は空です。

4

3 に答える 3

3

Nowhere in your code does it appear that you're requesting the Permission needed to access the user's email address or birthday

Check the permissions doc and make sure you're requesting the email and user_birthday permissions in your Authentication code.

于 2012-09-02T16:09:23.010 に答える
0

コードでそれを記述する方法を検索したところ、ログイン URL の範囲内で電子メールのアクセス許可を要求する必要があることがわかりました。

$params = array(
  'redirect_uri' => url_for('sfGuardAuth/loginWithFB', true),'scope' => 'email,user_birthday,user_location'
);
  $loginUrl = $facebook->getLoginUrl($params);
于 2012-09-03T06:52:13.687 に答える
0

これらの情報を受け取れない場合、その原因の 1 つは、ユーザー設定でそれらの共有が禁止されており、Facebook が警告を送信していないことが原因の 1 つです。

一部のユーザーは、構成で、電子メールまたはその他の情報の共有を禁止しているためです。

于 2012-09-02T13:21:09.363 に答える