[function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized

后端 未结 4 1899
孤街浪徒
孤街浪徒 2021-01-21 17:51

[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, a

4条回答
  •  一生所求
    2021-01-21 18:14

    task - fopen with basic http authentication.

    $auth_header = 'Authorization: Basic '.base64_encode("$user:$password");
    
    $f = fopen($url, $open_mode,false, stream_context_create(
        'http'=>array(
            'header' => array($auth_header,$some_other_header,$some_yet_header),
        ),
    ));
    

提交回复
热议问题