Facebook Apps 應用程式登入時進行請求授權


簡單說明一下
比如有一網址: http://example.com/apps
在用戶第一次進入此網址時,則要求用戶給予相應的權限 (自動跳轉到 Facebook 的授權頁面)
在用戶第二次進入此網址時,就不再請求,而可直接應用

相關的語法如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
// 輸出測試用字串
echo "This is a test";

// 建立請求字串
$q = http_build_query(array(
"api_key" => "[應用程式的 APP ID]",
"cancel_url" => "http://zeuik.com/index.php", // 按下取消時跳轉的頁面
"display" => "page", // 授權頁的顯示模式 page, popup, wap, touch
"fbconnect" => 0,
"next" => "http://zeuik.com/youtube/video.php?id=1", // 授權後跳轉到的頁面
"return_session" => 1, // 是否回傳用戶的 SESSION 資料
"session_version" => 3, // SESSION 版本
"v" => "1.0",
"canvas" => 1,
"req_perms" => "email,publish_stream,user_photo_video_tags,user_photos,friends_photo_video_tags,friends_photos,photo_upload" // 請求的權限
));
?>

<script type='text/javascript'>top.location.href = 'https://www.facebook.com/login.php?<?php echo $q; ?>';</script>