我正在使用一项要求我通过以下方式调用它的服务:
curl -u username:password -X POST "http://www.theirurl.com"
Run Code Online (Sandbox Code Playgroud)
但是,我想使用 Guzzle 而不是原始 CURL。有没有办法让 Guzzle 传递-u参数?我尝试了 User-Agent,但这不正确。
那不是用户代理,而是 HTTP 基本身份验证。
$client->post('http://www.theirurl.com/', ['auth' => ['username', 'password']]);
Run Code Online (Sandbox Code Playgroud)
http://guzzle.readthedocs.org/en/latest/request-options.html?highlight=auth#auth