[英]Facebook redirecting to canvas url instead of canvas page after app authorization
[英]Facebook App (canvas page) keeps redirecting to the index page
我無法弄清楚為什么每次我單擊應用程序內的鏈接(第1頁的第2頁)時,鏈接會轉到第2頁,但會自動重定向回第1頁。 這越來越令人沮喪。 我覺得我在下面的代碼中正確地完成了所有操作,因為它可以對用戶和所有內容進行身份驗證……但是唯一的問題是,如果沒有它自動返回索引頁面,我將無法導航。
$fb_app_id = "xxxxxxxx";
$fb_app_secret = "xxxxxxxxx";
$fb_scope = "email,user_birthday,user_location";
$fb_response_type = "token";
$canvas_page = "https://apps.facebook.com/app-name/";
require_once 'sdk/facebook.php';
$facebook = new Facebook(array(
'appId' => '' . $fb_app_id . '',
'secret' => '' . $fb_app_secret . '',
'cookie' => true,
));
$app_id = '' . $fb_app_id . '';
$auth_url = "http://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page) . ("&scope=" . $fb_scope . "&response_type=" . $fb_response_type . "");
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
if (empty($data["user_id"])) {
echo("<script> top.location.href='" . $auth_url . "'</script>");
} else {
$UserId = $data["user_id"];
$token = $facebook->getAccessToken();
$facebook->setAccessToken($token);
$user_profile = $facebook->api('/me/');
} ...
有人可以看一下,告訴我我做錯了什么嗎?
提前致謝!
問題解決了....
require_once 'sdk/facebook.php';
$facebook = new Facebook(array(
'appId' => '0000000000000000000',
'secret' => 'if-i-tell-ya-ill-have-to-kill-ya',
'cookie' => true,
));
$canvas_page = "https://apps.facebook.com/whatever/";
$auth_url = "http://www.facebook.com/dialog/oauth?client_id="
. $fb_app_id . "&redirect_uri=" . urlencode($canvas_page) . ("&scope=" . $fb_scope . "&response_type=" . $fb_response_type . "");
$signed_request = $_REQUEST["signed_request"];
$uid=$facebook->getuser();
if(empty($uid)){ echo("<script> top.location.href='" . $auth_url . "'</script>");}
else { // do something }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.