Example #1
0
 /**
  * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
  * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
  * empty. The result MUST be encoded again.
  *
  * Please note that the second encoding MUST NOT happen in the SignatureMethod, as
  * OAuthRequest handles this!
  * 
  * {@inheritdoc}
  */
 public function buildSignature($baseString, OAuth\Consumer $consumer, OAuth\Token $token = NULL)
 {
     $keyParts = [$consumer->getSecret(), $token ? $token->getSecret() : ""];
     $keyParts = Utils\Url::urlEncodeRFC3986($keyParts);
     $key = implode('&', $keyParts);
     return $key;
 }
Example #2
0
 public function __construct(OAuth\Consumer $consumer, Http\Url $url, $method = self::GET, array $post = [], array $headers = [], OAuth\Token $token = NULL)
 {
     $this->consumer = $consumer;
     $this->token = $token;
     $this->url = $url;
     $this->method = strtoupper($method);
     $this->headers = $headers;
     if (is_array($post) && !empty($post)) {
         $this->post = array_map(function ($value) {
             if ($value instanceof Http\UrlScript) {
                 return (string) $value;
             } elseif ($value instanceof \CURLFile) {
                 return $value;
             }
             return !is_string($value) ? Utils\Json::encode($value) : $value;
         }, $post);
     }
     $parameters = $this->getParameters();
     $defaults = ['oauth_version' => OAuth\DI\OAuthExtension::VERSION, 'oauth_nonce' => $this->generateNonce(), 'oauth_timestamp' => $this->generateTimestamp(), 'oauth_consumer_key' => $this->consumer->getKey()];
     if ($token && $token->getToken()) {
         $defaults['oauth_token'] = $this->token->getToken();
     }
     // Update query parameters
     $this->url->setQuery(array_merge($defaults, $parameters));
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function buildSignature($baseString, OAuth\Consumer $consumer, OAuth\Token $token = NULL)
 {
     $keyParts = [Utils\Url::urlEncodeRFC3986($consumer->getSecret()), Utils\Url::urlEncodeRFC3986($token ? $token->getSecret() : '')];
     $key = implode('&', Utils\Url::urlEncodeRFC3986($keyParts));
     return base64_encode(hash_hmac('sha1', $baseString, $key, TRUE));
 }