Trey
Trey

Reputation: 394

Facebook auth/canvas not displaying

Hi Everytime I go directly to the app everything works properly. However when I click on the tab for the app on the fan page it is blank in firefox and chrome, however in ie it says: This content cannot be displayed in a frame To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame.

What you can try: Open this content in a new window

Does anyone know why this is not working? Here's my php code at the top of my canvas page. Thanks!

<?php 

$app_id = "181247898619054";
$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$my_url = "https://apps.facebook.com/wellnessiq/";
session_register();
session_start();
header('P3P: CP="CAO PSA OUR"');

if (!isset($_REQUEST["code"]))
{
$_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
$dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" 
. $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=email&state="
. $_SESSION['state'];

echo("<script> top.location.href='" . $dialog_url . "'</script>");
exit;
}
$code = $_REQUEST['code'];
{
$token_url = "https://graph.facebook.com/oauth/access_token?"
. "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)
. "&client_secret=" . $app_secret . "&code=" . $code;

$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);

$graph_url = "https://graph.facebook.com/me?access_token=" 
. $params['access_token'];

$user = json_decode(file_get_contents($graph_url));
}

?>

Upvotes: 2

Views: 1643

Answers (1)

TommyBs
TommyBs

Reputation: 9646

I think this might be with how this is set-up. My guess is you have set the link for your fan page application to be the url of your canvas app on facebook.

e.g https://apps.facebook.com/wellnessiq/

Then when you click the tab on your page within facebook, it is essentially trying to load facebook in it again with another iFrame holding your app.

Try changing your page tab url to the full url of your site

e.g www.example.com/canvas.php

if that's not the case then trying post a bit more info if you can

Upvotes: 3

Related Questions