本文整理匯總了PHP中Zend_Oauth_Http_Utility::urlEncode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Oauth_Http_Utility::urlEncode方法的具體用法?PHP Zend_Oauth_Http_Utility::urlEncode怎麽用?PHP Zend_Oauth_Http_Utility::urlEncode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Oauth_Http_Utility
的用法示例。
在下文中一共展示了Zend_Oauth_Http_Utility::urlEncode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _getBaseSignatureString
/**
* Get base signature string
*
* @param array $params
* @param null|string $method
* @param null|string $url
* @return string
*/
protected function _getBaseSignatureString(array $params, $method = null, $url = null)
{
$encodedParams = array();
foreach ($params as $key => $value) {
$encodedParams[Zend_Oauth_Http_Utility::urlEncode($key)] = Zend_Oauth_Http_Utility::urlEncode($value);
}
$baseStrings = array();
if (isset($method)) {
$baseStrings[] = strtoupper($method);
}
if (isset($url)) {
// should normalise later
$baseStrings[] = Zend_Oauth_Http_Utility::urlEncode($this->normaliseBaseSignatureUrl($url));
}
if (isset($encodedParams['oauth_signature'])) {
unset($encodedParams['oauth_signature']);
}
$baseStrings[] = Zend_Oauth_Http_Utility::urlEncode($this->_toByteValueOrderedQueryString($encodedParams));
return implode('&', $baseStrings);
}
示例2: _toAuthorizationHeader
/**
* Generates a valid OAuth Authorization header based on the provided
* parameters and realm.
*
* @param array $params
* @param string $realm
* @return string
*/
protected function _toAuthorizationHeader(array $params, $realm = null)
{
$headerValue = array();
$headerValue[] = 'OAuth realm="' . $realm . '"';
foreach ($params as $key => $value) {
if (!preg_match("/^oauth_/", $key)) {
continue;
}
$headerValue[] = Zend_Oauth_Http_Utility::urlEncode($key) . '="' . Zend_Oauth_Http_Utility::urlEncode($value) . '"';
}
return implode(",", $headerValue);
}
示例3: testUrlEncodeCorrectlyEncodesU3001
public function testUrlEncodeCorrectlyEncodesU3001()
{
$string = '、';
$this->assertEquals('%E3%80%81', Zend_Oauth_Http_Utility::urlEncode($string));
}
示例4: getOauthHeader
/**
* Get OAuth 'Authentication' header string
*
* @return string
*/
public function getOauthHeader()
{
$this->_oauthParams['oauth_timestamp'] = time();
$this->_oauthParams['oauth_nonce'] = md5(uniqid(rand(), true));
// http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/5/spec.html
// Haven't fully implemented that spec, but the idea is the same.
// TODO: The server should validate this hash to be more secure
$this->_oauthParams['oauth_body_hash'] = $this->_getRequestHash();
$this->_generateOauthSignature('POST');
$headerValue = array();
foreach ($this->_oauthParams as $key => $value) {
$headerValue[] = Zend_Oauth_Http_Utility::urlEncode($key) . '="' . Zend_Oauth_Http_Utility::urlEncode($value) . '"';
}
return implode(",", $headerValue);
}