I'm trying to promote my app using app center but from the Web preview I can't visit the web site. The link that is called is http://www.myappsite.it/?fb_source=appcenter&fb_appcenter=1&code=a_long_string
From the index.php of myappsite I use this peace of php code to get the user coming from facebook
$code = $_REQUEST["code"];
if($_REQUEST['state'] == $_SESSION['state'] && !$user && strlen($code) > 0)
{
$token_url = "https://graph.facebook.com/oauth/access_token?" .
"client_id=" . $appId . "&redirect_uri=" . urlencode("http://www.myappsite.it/") .
"&client_secret=" . $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));
echo("Hello " . $user->name);
}
but $params['access_token'] is empty because the $token_url returns
{
"error": {
"message": "Error validating verification code.",
"type": "OAuthException",
"code": 100
}
}
how can I get the user logged in from tha app center preview web page?