Facebook应用认证问题

时间:2011-02-25 19:44:36

标签: php facebook facebook-authentication

我编写了以下代码来验证Facebook应用程序,但很多天它没有解决谷歌。 问题是当第一次访问应用程序时,用户会提示应用程序验证对话框。当用户允许应用程序时,它会一直闪烁网址。既不显示对话也不显示。关闭浏览器后,它运行正常。请问你能找出问题所在。我会非常感激的。

代码:

$canvas_page = "---my canvas url----"; //i removed actual url here!
// Create our Application instance (replace this with your appId and secret).
   $auth_url = "http://www.facebook.com/dialog/oauth?client_id="
            . $app_id . "&redirect_uri=" . urlencode($canvas_page) ."&scope=email,read_stream";
     $signed_request = $_REQUEST["signed_request"];

     list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

     $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

     if (!empty($data["user_id"])) {
         echo 'Hello: '.$data["user_id"];
     }else{
         echo "What is the hell";
          echo("<script> location.href='" . $auth_url . "'</script>");
     }

2 个答案:

答案 0 :(得分:2)

应该有效

 $canvas_page = "---my canvas url----"; //i removed actual url here! // Create our Application instance (replace this with your appId and secret).    $auth_url = "http://www.facebook.com/dialog/oauth?client_id="             . $app_id . "&redirect_uri=" . urlencode($canvas_page) ."&scope=email,read_stream";      $signed_request = $_REQUEST["signed_request"];       list($encoded_sig, $payload) = explode('.', $signed_request, 2);        $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);       if (!empty($data["user_id"])) {          echo 'Hello: '.$data["user_id"];      }else{          echo "What is the hell";           echo("<script> location.href='" . $auth_url . "'</script>");      } 

答案 1 :(得分:1)

使用:

echo("<script> top.location.href='" . $auth_url . "'</script>");

top