我正在尝试使用应用中心宣传我的应用,但是从网络预览我无法访问该网站.调用的链接是http://www.myappsite.it/?fb_source=appcenter&fb_appcenter=1&code=a_long_string
从myappsite的index.php我使用这个和平的PHP代码让用户来自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);
}
Run Code Online (Sandbox Code Playgroud)
但$ params ['access_token']为空,因为$ token_url返回
{
"error": {
"message": "Error validating verification code.",
"type": "OAuthException",
"code": 100
}
}
Run Code Online (Sandbox Code Playgroud)
如何让用户从应用程序中心预览网页登录?