my facebook app consists of some php pages it the first page appears in the canvas url i can get the user data from the signed_request parameter like this:
$app_id = "1111111111111111";
$canvas_page = "http://www.mydomain.com/fb/app/";
$auth_u开发者_JAVA百科rl = "https://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&redirect_uri=" . urlencode($canvas_page) . "&scope=email,read_stream";
$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';
}
but when i navigate to other pages or a page in an iframe within my app i can't see this parameter. so is it only the first page loaded in the canvas that the facebook sends this parame
Correct. Only the first page loaded into the iframe will receive the signed_request parameter. It is up to you to parse it there and then carry whatever data you need to subsequent pages.
精彩评论