当前位置: 首页>>代码示例>>PHP>>正文


PHP OAuth::urlencode方法代码示例

本文整理汇总了PHP中OAuth::urlencode方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuth::urlencode方法的具体用法?PHP OAuth::urlencode怎么用?PHP OAuth::urlencode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OAuth的用法示例。


在下文中一共展示了OAuth::urlencode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: normalize_params

 /**
  * Normalize all request parameters into a string.
  *
  *     $query = OAuth::normalize_params($params);
  *
  * [!!] This method implements [OAuth 1.0 Spec 9.1.1](http://oauth.net/core/1.0/#rfc.section.9.1.1).
  *
  * @param   array   request parameters
  * @return  string
  * @uses    OAuth::urlencode
  */
 public static function normalize_params(array $params)
 {
     // Encode the parameter keys and values
     $keys = OAuth::urlencode(array_keys($params));
     $values = OAuth::urlencode(array_values($params));
     // Recombine the parameters
     $params = array_combine($keys, $values);
     // OAuth Spec 9.1.1 (1)
     // "Parameters are sorted by name, using lexicographical byte value ordering."
     uksort($params, 'strcmp');
     // Create a new query string
     $query = array();
     foreach ($params as $name => $value) {
         if (is_array($value)) {
             // OAuth Spec 9.1.1 (1)
             // "If two or more parameters share the same name, they are sorted by their value."
             $value = natsort($value);
             foreach ($value as $duplicate) {
                 $query[] = $name . '=' . $duplicate;
             }
         } else {
             $query[] = $name . '=' . $value;
         }
     }
     return implode('&', $query);
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:37,代码来源:oauth.php

示例2: key

 /**
  * Get a signing key from a consumer and token.
  *
  *     $key = $signature->key($consumer, $token);
  *
  * [!!] This method implements the signing key of [OAuth 1.0 Spec 9](http://oauth.net/core/1.0/#rfc.section.9).
  *
  * @param   OAuth_Consumer  consumer
  * @param   OAuth_Token     token
  * @return  string
  * @uses    OAuth::urlencode
  */
 public function key(OAuth_Consumer $consumer, OAuth_Token $token = NULL)
 {
     $key = OAuth::urlencode($consumer->secret) . '&';
     if ($token) {
         $key .= OAuth::urlencode($token->secret);
     }
     return $key;
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:20,代码来源:signature.php

示例3: as_header

 /**
  * Convert the request parameters into an `Authorization` header.
  *
  *     $header = $request->as_header();
  *
  * [!!] This method implements [OAuth 1.0 Spec 5.4.1](http://oauth.net/core/1.0/#rfc.section.5.4.1).
  *
  * @return  string
  */
 public function as_header()
 {
     $header = array();
     foreach ($this->params as $name => $value) {
         if (strpos($name, 'oauth_') === 0) {
             // OAuth Spec 5.4.1
             // "Parameter names and values are encoded per Parameter Encoding [RFC 3986]."
             $header[] = OAuth::urlencode($name) . '="' . OAuth::urlencode($value) . '"';
         }
     }
     return 'OAuth ' . implode(', ', $header);
 }
开发者ID:rainyman2012,项目名称:fuel-oauth,代码行数:21,代码来源:request.php

示例4: getSignature

 protected function getSignature($method, $url, $params)
 {
     $signature = false;
     /**
      * Normalize method.
      */
     $method = strtoupper($method);
     /**
      * Normalize URL.
      *
      * $urlnormalize = OAuth::urlnormalize($url);
      * $url = $urlnormalize['url'];
      */
     /**
      * Remove `oauth_signature` if present.
      * Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
      */
     if (isset($params['oauth_signature'])) {
         unset($params['oauth_signature']);
     }
     /**
      * Generate key.
      */
     $keyParts = array($this->consumerSecret, $this->tokenSecret ? $this->tokenSecret : '');
     $key = implode('&', OAuth::urlencode($keyParts));
     switch ($this->signatureMethod) {
         case OAuth::SIG_METHOD_HMACSHA1:
             $baseParts = array($method, $url, OAuth::paramsBuild($params));
             $base = implode('&', OAuth::urlencode($baseParts));
             $signature = base64_encode(hash_hmac('sha1', $base, $key, true));
             break;
         case OAuth::SIG_METHOD_PLAINTEXT:
             $signature = $key;
             break;
     }
     if (false === $signature) {
         throw new Exception('Can\'t generate signature.');
     }
     return $signature;
 }
开发者ID:joksnet,项目名称:php-old,代码行数:40,代码来源:OAuth.php

示例5: as_header

 /**
  * Convert the request parameters into an `Authorization` header.
  *
  *     $header = $request->as_header();
  *
  * [!!] This method implements [OAuth 1.0 Spec 5.4.1](http://oauth.net/core/1.0/#rfc.section.5.4.1).
  *
  * @return  string
  */
 public function as_header()
 {
     $header = array();
     // Check for the existance of "realm"
     if (array_key_exists('realm', $this->params) and !empty($this->params['realm'])) {
         // OAuth Spec 5.4.1
         // "Parameter names and values are encoded per Parameter Encoding [RFC 3986]."
         $header[] = OAuth::urlencode('realm') . '="' . OAuth::urlencode($this->params['realm']) . '"';
     }
     foreach ($this->params as $name => $value) {
         if (strpos($name, 'oauth_') === 0) {
             // OAuth Spec 5.4.1
             // "Parameter names and values are encoded per Parameter Encoding [RFC 3986]."
             $header[] = OAuth::urlencode($name) . '="' . OAuth::urlencode($value) . '"';
         }
     }
     return 'OAuth ' . implode(', ', $header);
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:27,代码来源:request.php


注:本文中的OAuth::urlencode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。