facebook autorization S_REQUEST[“code”] 不返回任何内容并且 SSL 错误 107
我使用下面的代码。
$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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就我而言,
在 base_facebook.php 中添加“makeRequest”方法通常会有所帮助。另外,您还应该确保 $_SERVER 没有被某些脚本损坏。如果 $_SERVER 中的数据以错误的方式转义,它将无法工作。
另请参阅此答案。
In my case, it often helps to add
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.