I was looking at the example code below from the developers site outlining OAuth Authentication using PHP.
My question is: Why did they echo a script to redirect the user, rather than using header(“Location”) ?
//see link for full code...
if(empty($code)) {
$_SESSION['state'] = md5(uniqid(rand(), TRUE));
$dialog_url = "https://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url) . "&state="
. $_SESSION['state'];
echo("<script> top.location.href='" . $dialog_url . "'</script>");
}
//see link for full code...
Thanks.
The top.location would indicate breaking out of a iframe, a header location will only affect the immediate containing iframe.