PHP file_get_contents() 错误 - 返回 URL 需要使用基本身份验证进行身份验证
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能想从这里开始: 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
基本上:
http://username:[电子邮件受保护]/ ...
但是也许你可以尝试 Facebook API。
Basically:
http://username:[email protected]/...
But maybe you can try the Facebook API.