我的代码一直工作到昨天,突然间开始发生错误。不知道什么改变了所有。它也是基于Facebook Serve side authentication的代码。另外我还提到了其他类似标题的帖子,但试过他们没有太多运气的提及。Facebook错误:应用程序发生错误。请稍后再试
这里是my_url 以https试过代码
<?php
$app_id = "my app id";
$app_secret = "my app secret";
$my_url = "http://apps.facebook.com/myappnamespace";
//都与HTTP和HTTPS //与直接路径也试过应用程序,并没有正常工作。 session_start(); $ code = $ _REQUEST [“code”];
if(empty($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) . "&state="
. $_SESSION['state'];
echo("<script> top.location.href='" . $dialog_url . "'</script>");
}
if($_REQUEST['state'] == $_SESSION['state']) {
$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));
echo("Hello " . $user->name);
}
else {
echo("The state does not match. You may be a victim of CSRF.");
}
?>
这将它发送到facebook画布之外,而不是在画布中加载。 – pal4life 2012-03-23 20:49:34