Facebook 应用程序身份验证问题

发布于 2024-10-19 06:40:45 字数 943 浏览 1 评论 0原文

我编写了以下代码来验证 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>");
     }

I wrote the following code to authenticate a facebook application but instead of google many days it did not solve.
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>");
     }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木槿暧夏七纪年 2024-10-26 06:40:45

应该有效

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

It should work

 $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>");      } 
漆黑的白昼 2024-10-26 06:40:45

使用:

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

top一起使用!

use:

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

With top!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文