$baseUrl = 'http://foo';
$config = array();
$client = new Guzzle\Http\Client($baseUrl, $config);
为 Guzzle 设置默认 header 而不将其作为参数传递给每个 $client->post($uri, $headers)
的新方法是什么?
有 $client->setDefaultHeaders($headers)
但已弃用。
setDefaultHeaders is deprecated. Use the request.options array to specify default request options
最佳答案
如果您使用的是 Guzzle v=6.0.*
$client = new GuzzleHttp\Client(['headers' => ['X-Foo' => 'Bar']]);
read the doc , 有更多的选择。
关于php - 如何在 Guzzle 中设置默认标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17766626/