예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function buildSignature(Request $request, Consumer $consumer, Token $token = null)
 {
     $signatureBase = $request->getSignatureBaseString();
     $parts = [$consumer->secret, null !== $token ? $token->secret : ""];
     $parts = Util::urlencodeRfc3986($parts);
     $key = implode('&', $parts);
     return base64_encode(hash_hmac('sha1', $signatureBase, $key, true));
 }
예제 #2
0
 /**
  * Builds the Authorization: header
  *
  * @return string
  * @throws TwitterOAuthException
  */
 public function toHeader()
 {
     $first = true;
     $out = 'Authorization: OAuth';
     foreach ($this->parameters as $k => $v) {
         if (substr($k, 0, 5) != "oauth") {
             continue;
         }
         if (is_array($v)) {
             throw new TwitterOAuthException('Arrays not supported in headers');
         }
         $out .= $first ? ' ' : ', ';
         $out .= Util::urlencodeRfc3986($k) . '="' . Util::urlencodeRfc3986($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
  *
  * @return string
  */
 public function __toString()
 {
     return sprintf("oauth_token=%s&oauth_token_secret=%s", Util::urlencodeRfc3986($this->key), Util::urlencodeRfc3986($this->secret));
 }