Base_uri 参数未用于 GET 方法
Base_uri param not used for GET method
我使用 Guzzle 6 的 Symfony 项目出现问题。
我的service.yml:
ma_core_api.client:
class: 'GuzzleHttp\Client'
arguments:
- [base_uri: '%ma_core_api_base_url%']
我的客户端转储是:
object(GuzzleHttp\Client)[620]
private 'config' =>
array (size=8)
0 =>
array (size=1)
'base_uri' => string 'http://dev1.core.mobileangelo.net/app_dev.php/api/' (length=50)
'handler' =>
object(GuzzleHttp\HandlerStack)[616]
private 'handler' =>
object(Closure)[634]
...
private 'stack' =>
array (size=4)
...
private 'cached' => null
'allow_redirects' =>
array (size=5)
'max' => int 5
'protocols' =>
array (size=2)
...
'strict' => boolean false
'referer' => boolean false
'track_redirects' => boolean false
'http_errors' => boolean true
'decode_content' => boolean true
'verify' => boolean true
'cookies' => boolean false
'headers' =>
array (size=1)
'User-Agent' => string 'GuzzleHttp/6.2.1 curl/7.47.0 PHP/7.0.19-1+deb.sury.org~xenial+1' (length=63)
但是当我执行 GET 方法时,堆栈跟踪就像:
(object(EasyHandle),
array('errno' => '6', 'error' => 'Could not resolve host: v2', 'url' => 'http://v2/transactions/', 'content_type' => null, 'http_code' => '0', 'header_size' => '0', 'request_size' => '0', 'filetime' => '-1', 'ssl_verify_result' => '0', 'redirect_count' => '0', 'total_time' => '0.004181', 'namelookup_time' => '0', 'connect_time' => '0', 'pretransfer_time' => '0', 'size_upload' => '0', 'size_download' => '0', 'speed_download' => '0', 'speed_upload' => '0', 'download_content_length' => '-1', 'upload_content_length' => '-1', 'starttransfer_time' => '0', 'redirect_time' => '0', 'redirect_url' => '', 'primary_ip' => '', 'certinfo' => array(), 'primary_port' => '0', 'local_ip' => '', 'local_port' => '0'))
如您所见,我的 base_uri 参数被忽略了。
一些想法?
谢谢!
Services.yml需要这样做
services:
api.client:
class: 'GuzzleHttp\Client'
arguments:
- base_uri: 'http://apache.org'
就这样做:) base_url 之前的 - 将它定义为数组的索引..
我使用 Guzzle 6 的 Symfony 项目出现问题。
我的service.yml:
ma_core_api.client:
class: 'GuzzleHttp\Client'
arguments:
- [base_uri: '%ma_core_api_base_url%']
我的客户端转储是:
object(GuzzleHttp\Client)[620]
private 'config' =>
array (size=8)
0 =>
array (size=1)
'base_uri' => string 'http://dev1.core.mobileangelo.net/app_dev.php/api/' (length=50)
'handler' =>
object(GuzzleHttp\HandlerStack)[616]
private 'handler' =>
object(Closure)[634]
...
private 'stack' =>
array (size=4)
...
private 'cached' => null
'allow_redirects' =>
array (size=5)
'max' => int 5
'protocols' =>
array (size=2)
...
'strict' => boolean false
'referer' => boolean false
'track_redirects' => boolean false
'http_errors' => boolean true
'decode_content' => boolean true
'verify' => boolean true
'cookies' => boolean false
'headers' =>
array (size=1)
'User-Agent' => string 'GuzzleHttp/6.2.1 curl/7.47.0 PHP/7.0.19-1+deb.sury.org~xenial+1' (length=63)
但是当我执行 GET 方法时,堆栈跟踪就像:
(object(EasyHandle),
array('errno' => '6', 'error' => 'Could not resolve host: v2', 'url' => 'http://v2/transactions/', 'content_type' => null, 'http_code' => '0', 'header_size' => '0', 'request_size' => '0', 'filetime' => '-1', 'ssl_verify_result' => '0', 'redirect_count' => '0', 'total_time' => '0.004181', 'namelookup_time' => '0', 'connect_time' => '0', 'pretransfer_time' => '0', 'size_upload' => '0', 'size_download' => '0', 'speed_download' => '0', 'speed_upload' => '0', 'download_content_length' => '-1', 'upload_content_length' => '-1', 'starttransfer_time' => '0', 'redirect_time' => '0', 'redirect_url' => '', 'primary_ip' => '', 'certinfo' => array(), 'primary_port' => '0', 'local_ip' => '', 'local_port' => '0'))
如您所见,我的 base_uri 参数被忽略了。
一些想法? 谢谢!
Services.yml需要这样做
services:
api.client:
class: 'GuzzleHttp\Client'
arguments:
- base_uri: 'http://apache.org'
就这样做:) base_url 之前的 - 将它定义为数组的索引..