Example #1
0
 /**
  * @param Signature\SignatureMethod $method
  *
  * @return $this
  */
 public function setSignatureMethod(Signature\SignatureMethod $method)
 {
     $this->signatureMethods[$method->getName()] = $method;
     return $this;
 }
Example #2
0
 /**
  * Sign current request
  *
  * @param Signature\SignatureMethod $method
  *
  * @return $this
  */
 public function signRequest(Signature\SignatureMethod $method)
 {
     $this->url->setQueryParameter('oauth_signature_method', $method->getName());
     $signature = $method->buildSignature($this->getSignatureBaseString(), $this->consumer, $this->token);
     $this->url->setQueryParameter('oauth_signature', $signature);
     $parameters = $this->getParameters();
     ksort($parameters, SORT_STRING);
     $authHeader = NULL;
     foreach ($parameters as $key => $value) {
         if (in_array($key, $this->oauthHeader)) {
             $authHeader .= ' ' . $key . '="' . OAuth\Utils\Url::urlEncodeRFC3986($value) . '",';
             // Remove oauth from query parameter
             $this->url->setQueryParameter($key, NULL);
         }
     }
     if ($authHeader !== NULL) {
         $this->headers['Authorization'] = 'OAuth ' . trim(rtrim($authHeader, ','));
     }
     return $this;
 }