2014-12-02 120 views
1

狂飲3有URI模板允許的請求定義,例如Guzzle 5中的URI模板?

$request = $client->get(array('http://example.com{+path}{/segments*}{?query,data*}', array(
    'path'  => '/foo/bar', 
    'segments' => array('one', 'two'), 
    'query' => 'test', 
    'data'  => array(
     'more' => 'value' 
    ) 
))); 

就我而言,我希望利用這個「段」,但狂飲5似乎不定義這一點。

取而代之的是最接近的香港專業教育學院遇到了

*  $client = new Client([ 
*   'base_url' => [ 
*    'http://www.foo.com/{version}/', 
*    ['version' => '123'] 
*   ], 
*   'defaults' => [ 
*    'timeout'   => 10, 
*    'allow_redirects' => false, 
*    'proxy'   => '192.168.16.1:10' 
*   ] 
*  ]); 

但是,這是你看到適用於BASE_URL

反正我有可以使用URI模板像在狂飲3?

回答

0

你可能已經找到了答案,因爲你創建的職位,但在這裏是如何與狂飲5 使用URI模板(用簡單的例子)

$client = new Client([ 
    'base_url' => 'https://api.github.com', 
]); 

$response = $client->get(
    ['/users/{username}', ['username' => $username]], // URI template & Parameters 
    ['future' => true] // Options 
);