简体   繁体   English

Facebook应用程序认证问题

[英]Facebook application authentication issue

I wrote the following code to authenticate a facebook application but instead of google many days it did not solve. 我写了以下代码来验证Facebook应用程序,但是好多天Google都无法解决它。 The problem is the when the application is first accessed user is prompt to application authentication dialog. 问题在于,首次访问该应用程序时,会提示用户进入应用程序身份验证对话框。 when the user allows application it keeps blinking the url. 当用户允许应用程序时,它会不断闪烁网址。 neither shows dialog nor application. 既不显示对话框也不显示应用程序。 After closing the browser yes it runs fine. 关闭浏览器后,可以正常运行。 please can you find out what is the problem. 请您找出问题所在。 I will be very thankful. 我将非常感谢。

Code: 码:

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

它应该工作

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

use: 采用:

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

With top ! top

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM