我在文档中使用Facebook应用程序画布代码,并在我点击“允许”后继续重定向。不确定有什么问题。检查它是否是一个错误或只是我。来自于 http://developers.facebook.com/docs/appsonfacebook/tutorial/
<?php
$app_id = ""; //Added my app id
$canvas_page = ""; //Added my canvas page
$auth_url = "http://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page);
$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 {
echo ("Welcome User: " . $data["user_id"]);
}
?>
答案 0 :(得分:0)
我的建议是使用php Sdk它让你的每件事都变得更轻松。登录代码如下:
<?php
include_once('src/facebook.php');
$config = array(
'appId' => 'xxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxx',
'fileUpload' => FALSE, // optional
);
$canvas_page = ""; //Added my canvas page
$auth_url = "http://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page);
$uid=$facebook->getuser();
if(empty($uid)){ echo("<script> top.location.href='" . $auth_url . "'</script>");}
else { echo ("Welcome User: " . $uid);}