PayPal\Auth\Oauth\OAuthUtil::urlencode_rfc3986 PHP Метод

urlencode_rfc3986() публичный статический Метод

public static urlencode_rfc3986 ( $input )
    public static function urlencode_rfc3986($input)
    {
        if (is_array($input)) {
            return array_map(array('PayPal\\Auth\\Oauth\\OAuthUtil', 'urlencode_rfc3986'), $input);
        } else {
            if (is_scalar($input)) {
                $tmp1 = str_replace('%7E', '~', rawurlencode($input));
                $tmp2 = str_replace(".", "%2E", $tmp1);
                $tmp3 = str_replace("*", "%2A", $tmp2);
                $tmp4 = str_replace('+', ' ', $tmp3);
                $tmp = str_replace("-", "%2D", $tmp4);
                return $tmp;
                /*$tmp1=str_replace('%7E', '~', rawurlencode($input));
                  $tmp2= str_replace(".","%2E",$tmp1);
                    
                    
                  return $tmp;*/
            } else {
                return '';
            }
        }
    }

Usage Example

Пример #1
0
 /**
  * builds the Authorization: header
  */
 public function to_header($realm = null)
 {
     $first = true;
     if ($realm) {
         $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
         $first = false;
     } else {
         $out = 'Authorization: OAuth';
     }
     $total = array();
     foreach ($this->parameters as $k => $v) {
         if (substr($k, 0, 5) != "oauth") {
             continue;
         }
         if (is_array($v)) {
             throw new OAuthException('Arrays not supported in headers');
         }
         $out .= $first ? ' ' : ',';
         $out .= OAuthUtil::urlencode_rfc3986($k) . '="' . OAuthUtil::urlencode_rfc3986($v) . '"';
         $first = false;
     }
     return $out;
 }