/**
  * 
  * @param type $request
  * @param type $consumer
  * @param type $token
  * @return type
  */
 public function build_signature($request, $consumer, $token)
 {
     $base_string = $request->get_signature_base_string();
     $request->base_string = $base_string;
     $key_parts = array($consumer->secret, $token ? $token->secret : "");
     $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
     $key = implode('&', $key_parts);
     return base64_encode(hash_hmac('sha1', $base_string, $key, true));
 }
 public function build_signature($request, $consumer, $token)
 {
     $sig = array(OAuthUtil::urlencode_rfc3986($consumer->secret));
     if ($token) {
         array_push($sig, OAuthUtil::urlencode_rfc3986($token->secret));
     } else {
         array_push($sig, '');
     }
     $raw = implode("&", $sig);
     // for debug purposes
     $request->base_string = $raw;
     return OAuthUtil::urlencode_rfc3986($raw);
 }
Example #3
0
 /**
  * builds the Authorization: header
  */
 public function to_header()
 {
     $out = 'Authorization: OAuth realm=""';
     $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 .= ',' . OAuthUtil::urlencode_rfc3986($k) . '="' . OAuthUtil::urlencode_rfc3986($v) . '"';
     }
     return $out;
 }
Example #4
0
 /**
  * generates the basic string serialization of a token that a server
  * would respond to request_token and access_token calls with
  */
 function to_string()
 {
     return "oauth_token=" . OAuthUtil::urlencode_rfc3986($this->key) . "&oauth_token_secret=" . OAuthUtil::urlencode_rfc3986($this->secret);
 }