facebook autorization S_REQUEST[“code”] 不返回任何内容并且 SSL 错误 107

发布于 2025-01-06 06:35:43 字数 1606 浏览 2 评论 0原文

我使用下面的代码。

     $app_id = my_app_id;      
     $app_secret = my_app_secret;

     $canvas_page = my_canvas_page;



     $auth_url = "http://www.facebook.com/dialog/oauth?client_id=" 
            . $app_id . "&redirect_uri=" . urlencode($canvas_page) . "&scope=email,read_stream,publish_stream";


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


     $code = $_REQUEST["code"];


     $file = "help.txt";
     $fh = fopen($file, "w+") or die("File ($file) does not exist!");

     fwrite($fh,  $code); 
 fclose($fh);

$_REQUEST["code"] 返回空,并且出现错误 107 (net::ERR_SSL_PROTOCOL_ERROR)。但真实的url包含代码值

(https://plazma-tambov.ru/advanced/fb/?code=AQB_w2iFHofA8rzlr9FGD0EmA_BtWVhMmAJgsWo-YTgakgJ-YXibkd1_634pYZZL8UDds9ZlRHtKiWunG z5-2oWfKsrxpaur75t2PFPY9INuqCAL5kBtJsS_Bt9Vf-2WvHkDBtLYgzhUSk3InuV8IU3V6dwu9upGvH6ETDMLBY124JJBM3VMO6EF0eCjZg4ZsNU#=)

如果我添加下一个代码

    $token_url = "https://graph.facebook.com/oauth/access_token?"
       . "client_id=" . $app_id . "&redirect_uri=" . urlencode($canvas_page)
       . "&client_secret=" . $app_secret . "&code=" . $code;

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

真实的网址包含空的代码变量

(https://graph.facebook.com/oauth/access_token?client_id=MY_APP_ID&redirect_uri=https%3A%2F%2Fplazma-tambov .ru%2Fadvanced%2Ffb%2F&client_secret=MY_APP_SECRET&code=)

为什么S_REQUEST["code"] 没有返回任何内容?

I use this code below.

     $app_id = my_app_id;      
     $app_secret = my_app_secret;

     $canvas_page = my_canvas_page;



     $auth_url = "http://www.facebook.com/dialog/oauth?client_id=" 
            . $app_id . "&redirect_uri=" . urlencode($canvas_page) . "&scope=email,read_stream,publish_stream";


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


     $code = $_REQUEST["code"];


     $file = "help.txt";
     $fh = fopen($file, "w+") or die("File ($file) does not exist!");

     fwrite($fh,  $code); 
 fclose($fh);

$_REQUEST["code"] return empty and i have error 107 ( net::ERR_SSL_PROTOCOL_ERROR). But real url contain code value

(https://plazma-tambov.ru/advanced/fb/?code=AQB_w2iFHofA8rzlr9FGD0EmA_BtWVhMmAJgsWo-YTgakgJ-YXibkd1_634pYZZL8UDds9ZlRHtKiWunGz5-2oWfKsrxpaur75t2PFPY9INuqCAL5kBtJsS_Bt9Vf-2WvHkDBtLYgzhUSk3InuV8IU3V6dwu9upGvH6ETDMLBY124JJBM3VMO6EF0eCjZg4ZsNU#=)

If i add next code

    $token_url = "https://graph.facebook.com/oauth/access_token?"
       . "client_id=" . $app_id . "&redirect_uri=" . urlencode($canvas_page)
       . "&client_secret=" . $app_secret . "&code=" . $code;

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

the real url contain empty for code variable

(https://graph.facebook.com/oauth/access_token?client_id=MY_APP_ID&redirect_uri=https%3A%2F%2Fplazma-tambov.ru%2Fadvanced%2Ffb%2F&client_secret=MY_APP_SECRET&code=)

Why S_REQUEST["code"] returns nothing ?

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

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

发布评论

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

评论(1

慕烟庭风 2025-01-13 06:35:43

就我而言,

$opts[CURLOPT_SSL_VERIFYPEER] = false;
$opts[CURLOPT_SSL_VERIFYHOST] = 0;

在 base_facebook.php 中添加“makeRequest”方法通常会有所帮助。另外,您还应该确保 $_SERVER 没有被某些脚本损坏。如果 $_SERVER 中的数据以错误的方式转义,它将无法工作。

另请参阅此答案

In my case, it often helps to add

$opts[CURLOPT_SSL_VERIFYPEER] = false;
$opts[CURLOPT_SSL_VERIFYHOST] = 0;

in the "makeRequest" method in base_facebook.php. Also you should make sure that $_SERVER is NOT damaged by some script. It won't work if the data in $_SERVER is escaped in a wrong way.

See also this answer.

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