0

我编写了以下代码来验证 facebook 应用程序,但是很多天它都没有解决,而不是 google。问题是首次访问应用程序时,用户会提示应用程序身份验证对话框。当用户允许应用程序时,它会不断闪烁 url。既不显示对话框也不显示应用程序。关闭浏览器后是的,它运行良好。请你找出问题所在。我将非常感激。

代码:

$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>");
     }
4

2 回答 2

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>");      } 
于 2011-10-05T05:01:37.300 回答
1

利用:

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

top

于 2011-02-26T17:00:08.340 回答