PHP file_get_contents() 错误 - 返回 URL 需要使用基本身份验证进行身份验证

发布于 2025-01-01 05:47:58 字数 800 浏览 3 评论 0原文

file_get_contents(https://graph.facebook.com/oauth/access_token?client_id=777445576857891&redirect_uri=http% 3A%2F%2Fwww.test.org%2Fsocialmedia%2Ffacebook%2Fcontroller.php&client_secret=e65302ed939a9150ab718720aae923fe&am p;代码=AQAMoaETajPO7s5eLSIQJ1yaOJHqSqRlY1SIGU5ZOxmjC-L93ukpw9Fg3jP8mGOhaiHIACFDQ02O9FW3ikfi90SjiuxpK_IPqTj9kRdRU9PTW n3Yapm_E9k2zh_k7zm48NH5yGiha9FpdkiOVzpBrAL_Q5DvCZXaqa9rnYfSwxctteyf_AJ66Cn0UprRGz0-acs#=&display=popup) [函数.文件获取内容]: 打开流失败:HTTP 请求失败! HTTP/1.0 400 错误请求

我收到上述错误,并认为这是因为为 redirect_uri 设置的 URL

需要身份验证。如何将用户名和密码添加到 URL 中?

编辑我已将redirect_uri更改为不需要身份验证的redirect_uri,但仍然不起作用。还更改了 Facebook 开发者应用程序设置中的站点 URL。

还按照一些人的建议尝试使用 CURL,但没有返回任何内容,没有错误消息,也没有访问令牌。

file_get_contents(https://graph.facebook.com/oauth/access_token?client_id=777445576857891&redirect_uri=http%3A%2F%2Fwww.test.org%2Fsocialmedia%2Ffacebook%2Fcontroller.php&client_secret=e65302ed939a9150ab718720aae923fe&code=AQAMoaETajPO7s5eLSIQJ1yaOJHqSqRlY1SIGU5ZOxmjC-L93ukpw9Fg3jP8mGOhaiHIACFDQ02O9FW3ikfi90SjiuxpK_IPqTj9kRdRU9PTWn3Yapm_E9k2zh_k7zm48NH5yGiha9FpdkiOVzpBrAL_Q5DvCZXaqa9rnYfSwxctteyf_AJ66Cn0UprRGz0-acs#=&display=popup)
[function.file-get-contents]:
failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request

I get the above error and think this is because the URL set for redirect_uri

requires authentication. How do I add the username and password to the URL?

EDIT I have changed the redirect_uri to one that does not require authentication and still dos not work. Also changed the Site URL within Facebook Developer App setup.

Also tried using CURL as a few people have suggested and nothing is returned, no error messages and no access token.

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

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

发布评论

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

评论(2

意犹 2025-01-08 05:47:59

您可能想从这里开始: http://developers.facebook.com/

在旁注中,尝试使用cURL 函数而不是 file_get_contents。它更快:
https://stackoverflow.com/questions/555523/file-获取内容与curl-什么具有更好的性能

You may wanna start here: http://developers.facebook.com/

On a side note, try using cURL functions instead of file_get_contents. It's faster:
https://stackoverflow.com/questions/555523/file-get-contents-vs-curl-what-has-better-performance

蹲墙角沉默 2025-01-08 05:47:59

基本上: http://username:[电子邮件受保护]/ ...

但是也许你可以尝试 Facebook API。

Basically: http://username:[email protected]/...

But maybe you can try the Facebook API.

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