4

ユーザーの誕生日を表示するFacebookアプリを作っています........

     <?
         require_once('php-sdk/facebook.php');
         $config = array(
                          'appId' => 'YOUR_APP_ID',
                          'secret' => 'YOUR_APP_SECRET',
                         );

         $facebook = new Facebook($config);
         $user_id = $facebook->getUser();
     ?>
     <html>
     <head></head>
     <body>

     <?
            if($user_id) 
            {

                  // We have a user ID, so probably a logged in user.
                  // If not, we'll get an exception, which we handle below.
                  try 
                  {

                        $user_profile = $facebook->api('/me','GET');
                        echo "Name: " . $user_profile['name'];

                        // Birth Date to be printed here........
                       echo "DOB:  ".$user_profile['birthday'];
                  } 
                  catch(FacebookApiException $e) 
                  {
                       // If the user is logged out, you can have a 
                       // user ID even though the access token is invalid.
                      // In this case, we'll get an exception, so we'll
                      // just ask the user to login again here.
                     $login_url = $facebook->getLoginUrl(); 
                     echo 'Please <a href="' . $login_url . '">login.</a>';
                     error_log($e->getType());
                     error_log($e->getMessage());
                  }   
             } 
             else 
             {

                    // No user, print a link for the user to login
                    $login_url = $facebook->getLoginUrl();
                    echo 'Please <a href="' . $login_url . '">login.</a>';

              }
     ?>

     </body>
     </html>

さて、問題はThis prints the name as expected but prints nothing in place on date of birth.......さらに参照すると、Facebookのアクセス許可(拡張)という用語について聞いた.....そして次のリンクから http://developers.facebook.com/docs/reference /api/ユーザー/

users_birthdayアクセス許可またはを有効にする必要があることがわかりましたfriends_birthday

さて、どのようにphpコードで有効にしますか?? ...サンプルを手伝ってください....... この質問がばかげているようでしたら申し訳ありません。私はFacebookアプリ開発の新参者であり、PHPの初心者でもあります.....stackoverflow.comで他の例を試しましたが、あまり役に立ちませんでした......

4

2 に答える 2