我的代碼一直工作到昨天,突然間開始發生錯誤。不知道什麼改變了所有。它也是基於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