我以前成功地使用了guzzlehttp/guzzle v.6.*
带有身份验证参数的包,如下所示:
$client = new GuzzleClient([
'base_uri' => $base_uri ,
'auth' => [ $username, $password ]
]);
这很好用。但是,我现在正在尝试使用该"guzzlehttp/guzzle-services": "0.5.*"
包来更轻松地使用 API 端点。
使用 guzzle-services 的 Github页面中的以下示例:
use GuzzleHttp\Client;
use GuzzleHttp\Command\Guzzle\GuzzleClient;
use GuzzleHttp\Command\Guzzle\Description;
$client = new Client();
$description = new Description([
'baseUrl' => 'http://httpbin.org/',
'operations' => [
'testing' => [
'httpMethod' => 'GET',
'uri' => '/get/{foo}',
'responseModel' => 'getResponse',
'parameters' => [
'foo' => [
'type' => 'string',
'location' => 'uri'
],
'bar' => [
'type' => 'string',
'location' => 'query'
]
]
]
],
'models' => [
'getResponse' => [
'type' => 'object',
'additionalProperties' => [
'location' => 'json'
]
]
]
]);
$guzzleClient = new GuzzleClient($client, $description);
$result = $guzzleClient->testing(['foo' => 'bar']);
使用包时,我如何以及在哪里添加身份验证参数"guzzlehttp/guzzle-services": "0.5.*"
?
我已经尝试了所有可能的方法,但无法让它发挥作用。