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。有机%2Fsocialmedia%2Ffacebook%2Fcontroller.php & client_secret = e65302ed939a9150ab718720aae923fe &代码= AQAMoaETajPO7s5eLSIQJ1yaOJHqSqRlY1SIGU5ZOxmjC-L93ukpw9Fg3jP8mGOhaiHIACFDQ02O9FW3ikfi90SjiuxpK_IPqTj9kRdRU9PTWn3Yapm_E9k2zh_k7zm48NH5yGiha9FpdkiOVzpBrAL_Q5DvCZXaqa9rnYfSwxctteyf_AJ66Cn0UprRGz0-ACS#= &显示弹出=) [function.file-GET-内容]: 未能打开流:HTTP请求失败! HTTP/1.0 400错误的请求PHP file_get_contents()函数错误 - 返回URL需要与基本认证认证

我得到上述错误,并认为这是因为网址redirect_uri

设置需要验证。如何将用户名和密码添加到URL?

编辑我已将redirect_uri更改为不需要身份验证但仍无法正常工作的redirect_uri。还在Facebook Developer App安装程序中更改了网站URL。

也尝试使用CURL作为一些人已经建议,没有任何返回,没有错误消息和访问令牌。

+0

完全重复http://*.com/questions/9080037/php-file-get-contents-error-page-needs-authenticating – Crontab 2012-01-31 14:46:45

+0

http://*.com/questions/8017062/facebook-authentication-throws-errors-for-a-few-users – Mob 2012-01-31 14:47:59

基本上是:http://username:[email protected]/...

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

+0

尝试尝试将上面列出的用户名和密码添加到redirect_uri参数中,但仍然出现错误。 – LeeTee 2012-01-31 15:41:38

+0

外部url上的file_get_contents是相当邪恶的。你不应该这样做。使用套接字或facebookapi – jwacalex 2012-01-31 16:50:20

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

在一个侧面说明,请尝试使用替代的file_get_contents卷曲功能。它的速度更快: https://*.com/questions/555523/file-get-contents-vs-curl-what-has-better-performance

+0

谢谢我已阅读通过http://developers.facebook.com/,并使用从那里使用file_get_contents()的代码,但我很遗憾undertsnad为什么它不工作。 – LeeTee 2012-01-31 16:03:22