I created a facebook application that when opened with apps.facebook.com/myappperfectly points to my index.php domain and can be seen in the facebook application window, but the problem arises when I try to redirect it to my registration page, it gets redirected to my domain, I want all pages were viewed in the facebook application window. tried to use the fb: redirect sdk function, but the site says they will blame these codes.
<?php
if(preg_match('/apps.facebook.com/',$_SERVER[HTTP_REFERER])){
$app_id = '';
$api_key = '';
$app_secret = '';
$canvas_page = 'mydomain/index.php';
$auth_url = "http://www.facebook.com/dialog/oauth?client_id=".
$app_id."&redirect_uri=".urlencode($canvas_page)."&scope=email,user_birthday,user_interests,user_about_me";
$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{
$canvas_page="mydomain/register.php";
echo ("<script> top.location.href='".$auth_url."'</script>");
}
}else{
echo "No facebook";
}
?>
the code works fine until echo("<script> top.location.href='" .$auth_url ."'</script>")when $canvas_page- the one that is installed in the form of the facebook application; but redirects to another page when $canvas_pagechanged to my register.php page. where am i wrong
early
source
share