1
我正在使用Guzzle 3處理超媒體HTTP API,並將URL路徑用作參數存在一些問題。該服務將返回訪問資源的URL路徑,除了參數化路徑正在URLEncoded之外,該服務主要工作。如何防止URLEncoding操作參數中的Guzzle 3?
這裏的工作在服務說明
"getWidget": {
"uri": "{path}",
"summary": "Get Widget",
"httpMethod": "GET",
"responseType": "class",
"responseClass": "Service\\Responses\\Widget",
"parameters": {
"path": {
"location": "uri"
}
}
}
我執行的操作後的樣品做:
$client = WidgetClient::factory(array('base_url' => 'example.com'));
$args = array('path' => '/widget/abc123');
$command = $client->getCommand('getWidget', $args);
$result = $command->execute();
當執行客戶端的請求:http://example.com/%2Fwidget%2Fabc123
而不是http://example.com/widgetabc123
我追蹤了參數處理到UriTemplate::expandMatch()
,它執行rawurlencode($variable)
調用編碼參數 - 但我看不到清晰的方式來避免編碼。
因此,使用Guzzle 3及其服務描述,如何將URL路徑作爲參數傳遞,而不需要使用URLEncoded?