[英]Facebook App (canvas page) keeps redirecting to the index page
I am unable to figure out why every time I click on a link inside of my app (page 2 from page 1), it goes to page 2 but automatically redirects back to page one. 我无法弄清楚为什么每次我单击应用程序内的链接(第1页的第2页)时,链接会转到第2页,但会自动重定向回第1页。 This is getting frustrating. 这越来越令人沮丧。 I feel like I have done everything correctly in the code below because it authenticates the user and everything as it should... but the only problem is, I can not navigate anywhere without it automatically going back to the index page. 我觉得我在下面的代码中正确地完成了所有操作,因为它可以对用户和所有内容进行身份验证……但是唯一的问题是,如果没有它自动返回索引页面,我将无法导航。
$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/');
} ...
Can someone look at this and tell me what it is that I am doing wrong? 有人可以看一下,告诉我我做错了什么吗?
Thanks in advance! 提前致谢!
Problem solved.... 问题解决了....
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.