示例#1
0
 public function buildSignature($request, $consumer, $token)
 {
     $baseString = $request->getSignatureBaseString();
     $request->baseString = $baseString;
     $keyParts = array($consumer->secret, $token ? $token->secret : "");
     $keyParts = Zeed_OAuth_Util::urlencode_rfc3986($keyParts);
     $key = implode('&', $keyParts);
     return base64_encode(hash_hmac('sha1', $baseString, $key, true));
 }
示例#2
0
 /**
  * builds the Authorization: header
  */
 public function toHeader($realm = null)
 {
     $first = true;
     if ($realm) {
         $out = 'Authorization: OAuth realm="' . Zeed_OAuth_Util::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 Zeed_OAuth_Exception('Arrays not supported in headers');
         }
         $out .= $first ? ' ' : ',';
         $out .= Zeed_OAuth_Util::urlencode_rfc3986($k) . '="' . Zeed_OAuth_Util::urlencode_rfc3986($v) . '"';
         $first = false;
     }
     return $out;
 }
示例#3
0
 /**
  * generates the basic string serialization of a token that a server
  * would respond to request_token and access_token calls with
  */
 function __toString()
 {
     return "oauth_token=" . Zeed_OAuth_Util::urlencode_rfc3986($this->key) . "&oauth_token_secret=" . Zeed_OAuth_Util::urlencode_rfc3986($this->secret);
 }