本文整理匯總了PHP中XString::urlencode_rfc3986方法的典型用法代碼示例。如果您正苦於以下問題:PHP XString::urlencode_rfc3986方法的具體用法?PHP XString::urlencode_rfc3986怎麽用?PHP XString::urlencode_rfc3986使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類XString
的用法示例。
在下文中一共展示了XString::urlencode_rfc3986方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sign
protected function sign($url, $method, $params, $oauth_token_secret = null)
{
/*{{{*/
uksort($params, 'strcmp');
$pairs = array();
foreach ($params as $key => $value) {
$key = XString::urlencode_rfc3986($key);
if (is_array($value)) {
// If two or more parameters share the same name, they are sorted by their value
// Ref: Spec: 9.1.1 (1)
natsort($value);
foreach ($value as $duplicate_value) {
$pairs[] = $key . '=' . XString::urlencode_rfc3986($duplicate_value);
}
} else {
$pairs[] = $key . '=' . XString::urlencode_rfc3986($value);
}
}
$sign_parts = XString::urlencode_rfc3986(implode('&', $pairs));
$base_string = implode('&', array(strtoupper($method), XString::urlencode_rfc3986($url), $sign_parts));
$key_parts = array(XString::urlencode_rfc3986($this->appsecret), XString::urlencode_rfc3986($oauth_token_secret));
$key = implode('&', $key_parts);
return base64_encode(XString::hash_hmac('sha1', $base_string, $key, true));
}