使用 PHP file_get_contents 调用 ODATA 服务

我需要在 Debian 9 下使用 php7.0 调用 ODATA 服务。


我正在尝试使用“file_get_contents”函数,但是当我运行脚本时


$call_opts=array(

    "http"=>array(

        "method"=>"GET",

        "header"=>"Content-type: application/x-www-form-urlencoded",

    )

);

//

$call_context=stream_context_create($call_opts);

$call_res_json=file_get_contents($url,false);

它返回以下内容:


Warning: file_get_contents(http://<URL>): failed to open stream: HTTP request failed! HTTP/1.0 401 Unauthorized

我也有用户名和密码,但我不知道如何使用它们。


守着一只汪
浏览 129回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP