index.php
require_once ('../src/facebook.php');
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'cookie' => true,
));
$session = $facebook->getSession();
if (!empty($session)) {
try {
$uid = $facebook->getUser();
$user = $facebook->api('/me');
echo 'session found';
} catch (Exception $e) {}
if(!empty($user)) {
include 'result.php';
}
else {
$url = $facebook->GetLoginUrl(array('canvas' => 1,
'fbconnect' => 0,
'req_perms' => 'publish_stream, email, user_birthday, user_hometown, user_location, user_religion_politics, user_relationships, friends_about_me, friends_relationships',
'next' => 'http://www.applicationsite.com/index.php',
'cancel_url' => $appCanvasPage ));
#echo 'no user -> link to login';
echo '<a href="'.$url.'">Click here to install the app</a>;
}
}
else {
$url = $facebook->GetLoginUrl(array('canvas' => 1,
'fbconnect' => 0,
'req_perms' => 'publish_stream, email, user_birthday, user_hometown, user_location, user_religion_politics, user_relationships, friends_about_me, friends_relationships',
'next' =>'http://www.applicationsite.com/index.php',
'cancel_url' => $appCanvasPage ));
#echo 'no session -> link to login';
echo '<a href="'.$url.'">Click here to install the app</a>;
}
?>
選択.php
just to html links to :
http://www.applicationsite.com/index.php?¶m=1
http://www.applicationsite.com/index.php?¶m=1
結果.php
<?php
extract($_GET);
if (isset($param)){
I show my result
}
else
{
include 'choice.php';
}
?>
最初にページを起動すると、「セッションなし」リンクが表示されるので、クリックしてアクセス許可を提供するように求められます。「許可」をクリックすると、「choice.php」ページにリダイレクトされます。つまり、$ params が設定されていません。それは素晴らしいことです。
しかし、それをクリックすると、「セッションなし」リンクのあるインデックスページに戻り、リンクをもう一度クリックする必要があり、「choice.php」ページに戻ります。そして私は回り続けます。