我无法弄清楚为什么每次单击应用程序内部的链接(第 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/');
} ...
有人可以看看这个并告诉我我做错了什么吗?
提前致谢!