私は自分のアプリにこのコードを使用して、ユーザーがログインし、ユーザーのイベントを作成および編集するためのアプリのアクセス許可を取得できるようにしています。これは正常に機能していましたが、今日試してみると、ページは無限に更新され続けます。毎回認証コードを変更します。何が起こっているのかわかりません。
<?php
// Include facebook php api
require_once("lib/facebook.php");
// Setup app configuration
$config = array();
$config['appId'] = 'APP_ID';
$config['secret'] = 'APP_SECRET';
$config['cookie'] = true;
$config['fileUpload'] = true;
// set app id & canvas page for location variable
$app_id = 'APP_ID';
$canvas_page = "https://apps.facebook.com/mixityhc/";
$location = "https://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page) . "&scope=publish_stream,email,create_event,rsvp_event,user_events,friends_events";
// create new instance of facebook object
$facebook = new Facebook($config);
// Get user id
$fbID = $facebook->getUser();
// Get the current access token
$access_token = $facebook->getAccessToken();
// check if we have valid user
if ($fbID) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$fb_user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
$fbID = NULL;
// seems we don't have enough permissions
// we use javascript to redirect user instead of header() due to Facebook bug
print '<script language="javascript" type="text/javascript"> top.location.href="'. $location .'"; </script>';
// kill the code so nothing else will happen before user gives us permissions
die();
}
} else {
// seems our user hasn't logged in, redirect him to a FB login page
print '<script language="javascript" type="text/javascript"> top.location.href="'. $location .'"; </script>';
// kill the code so nothing else will happen before user gives us permissions
die();
}
// Get user email address
$email = $fb_user_profile['email'];
どんな助けでも大歓迎ですありがとう