[function.fopen]:打开流失败:HTTP 请求失败! HTTP/1.1 401 未经授权
[function.fopen]:打开流失败:HTTP 请求失败! HTTP/1.1 401 Unauthorized
我定期收到此错误,即它仅在随机时间发生,任何想法会导致此错误,我已检查我的 php.ini 并将allow_url_fopen 设置为 true。
[function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized
I am periodically getting this error, i.e it is only happening at random times, any ideas what would cause this, i have checked my php.ini and allow_url_fopen is set to true.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果站点需要基本身份验证,您可以通过以下方式提供凭据:
如果它使用摘要身份验证,您必须通过读取失败响应的标头并发送具有正确标头的新响应来手动处理它。请参阅 HTTP 上下文选项 了解如何读取和设置标头并了解如何消化适用于使用 PHP 进行 HTTP 身份验证。
您还可以使用 cURL 扩展 或 HTTP PECL 扩展。
If the site requires basic authentication, you can give your credentials this way:
If it uses digest authentication, you'll have to handle it manually by reading the headers of the failed response and sending a new one with the correct headers. See HTTP context options for how to read and set headers and see how digest works in HTTP authentication with PHP.
You can also use the cURL extension or the HTTP PECL extension.
状态代码定义
Status Code Definitions
正如玛吉指出的那样,您正在尝试访问需要身份验证的网站。
fopen()
不支持 HTTP 基本身份验证,因此您必须使用客户端URL库来实现此类功能。这已经讨论过。
You are trying to access a site that requires authentication, as maggie pointed out.
fopen()
does not support HTTP Basic Authentication, so you must use the Client URL Library to achieve such functionalities.This has been discussed before.
任务 - fopen 具有基本的 http 身份验证。
task - fopen with basic http authentication.