本文整理汇总了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);
}