Fawad Ghafoor
Fawad Ghafoor

Reputation: 6217

facebook permission not working in iframe app

i want to go to next page in an iframe based application in facebook and i want to get permission in that page but permission code didnt work in next page. although working in default index page here is my code this work fine in index.php but not working redirect page

$app_id = '107919565956374';

$canvas_page = 'http://www.roohware.net/products/mytestapp/';

$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"]);
}

Upvotes: 0

Views: 1176

Answers (3)

ceasar
ceasar

Reputation: 1

Use this one:

        echo "<fb:redirect url={{$auth_url}} />";

Upvotes: 0

user713085
user713085

Reputation: 61

replace

echo("<script> top.location.href='" . $auth_url . "'</script>");

with

echo '<fb:redirect url="'.$auth_url.'" />

Upvotes: 0

Arun David
Arun David

Reputation: 2784

Rather than

echo("<script> top.location.href='" . $auth_url . "'</script>");

Try with,

echo "<a target='_parent' href='" . $auth_url . "'>Allow application</a>";

Upvotes: 2

Related Questions