本文整理匯總了PHP中Guzzle\Http\Url::getQuery方法的典型用法代碼示例。如果您正苦於以下問題:PHP Url::getQuery方法的具體用法?PHP Url::getQuery怎麽用?PHP Url::getQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Guzzle\Http\Url
的用法示例。
在下文中一共展示了Url::getQuery方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: baseString
/**
* Generate a base string for a HMAC-SHA1 signature
* based on the given a url, method, and any parameters.
*
* @param Url $url
* @param string $method
* @param array $parameters
*
* @return string
*/
protected function baseString(Url $url, $method = 'POST', array $parameters = array())
{
$baseString = rawurlencode($method) . '&';
$schemeHostPath = Url::buildUrl(array('scheme' => $url->getScheme(), 'host' => $url->getHost(), 'path' => $url->getPath()));
$baseString .= rawurlencode($schemeHostPath) . '&';
$data = array();
parse_str($url->getQuery(), $query);
foreach (array_merge($query, $parameters) as $key => $value) {
$data[rawurlencode($key)] = rawurlencode($value);
}
ksort($data);
array_walk($data, function (&$value, $key) {
$value = $key . '=' . $value;
});
$baseString .= rawurlencode(implode('&', $data));
return $baseString;
}
示例2: baseString
/**
* Generate a base string for a HMAC-SHA1 signature
* based on the given a url, method, and any parameters.
*
* @param Url $url
* @param string $method
* @param array $parameters
*
* @return string
*/
protected function baseString(Url $url, $method = 'POST', array $parameters = array())
{
$baseString = rawurlencode($method) . '&';
$schemeHostPath = Url::buildUrl(array('scheme' => $url->getScheme(), 'host' => $url->getHost(), 'path' => $url->getPath()));
$baseString .= rawurlencode($schemeHostPath) . '&';
$data = array();
parse_str($url->getQuery(), $query);
$data = array_merge($query, $parameters);
// normalize data key/values
array_walk_recursive($data, function (&$key, &$value) {
$key = rawurlencode(rawurldecode($key));
$value = rawurlencode(rawurldecode($value));
});
ksort($data);
$baseString .= $this->queryStringFromData($data);
return $baseString;
}