Exemple #1
0
 /**
  * Get base
  *
  * @param mixed $method HTTP method used in the request
  * @param mixed $url    URL of the request
  * @param array $params Parameters in the request
  *
  * @return string Base signature string
  */
 public function getBase($method, $url, array $params)
 {
     if (array_key_exists('oauth_signature', $params)) {
         unset($params['oauth_signature']);
     }
     $parts = array($method, reset(explode('?', $url)), HTTP_OAuth::buildHTTPQuery($params));
     $base = implode('&', HTTP_OAuth::urlencode($parts));
     $this->debug('Signing with base string: ' . $base);
     return $base;
 }
 /**
  * Get base
  *
  * @param mixed $method HTTP method used in the request
  * @param mixed $url    URL of the request
  * @param array $params Parameters in the request
  *
  * @return string Base signature string
  */
 public function getBase($method, $url, array $params)
 {
     if (array_key_exists('oauth_signature', $params)) {
         unset($params['oauth_signature']);
     }
     
     # BEGIN HACK
     # 2011.04.06 Roman Kallweit
     # prevent warning "strict: -Only variables should be passed by reference-
     /* original code:
     $croppedUrl = reset(explode('?', $url));
     */
     $explode = explode('?', $url);
     $croppedUrl = reset( $explode );
     # END HACK
     
     $parts = array($method, $croppedUrl,
         HTTP_OAuth::buildHTTPQuery($params));
     $base  = implode('&', HTTP_OAuth::urlencode($parts));
     $this->debug('Signing with base string: ' . $base);
     return $base;
 }
 /**
  * Get authorize url
  *
  * @param string $url        Authorize url
  * @param array  $additional Additional parameters for the auth url
  *
  * @return string Authorize url
  */
 public function getAuthorizeUrl($url, array $additional = array())
 {
     $params = array('oauth_token' => $this->getToken());
     $params = array_merge($additional, $params);
     return sprintf('%s?%s', $url, HTTP_OAuth::buildHTTPQuery($params));
 }
Exemple #4
0
 /**
  * Prepare body
  *
  * Sets the body if nesscary
  *
  * @return void
  */
 protected function prepareBody()
 {
     if ($this->headersSent() && $this->getBody() !== '') {
         $this->err('Body already sent, not setting');
     } else {
         $this->setBody(HTTP_OAuth::buildHTTPQuery($this->getParameters()));
     }
 }
Exemple #5
0
 public function testBuildHTTPQuery()
 {
     $array = array('oauth_consumer_key' => 'e1nTvIGVCPkbfqZdIE7OyA', 'oauth_token' => 'kRmeTe0wvuIJrIUbjoOfc4UZcUerJKR67BfXy20UM', 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_signature' => '6WvHOHROOBkKcP3YrpnEHNbn1y4=', 'oauth_timestamp' => '1245711961', 'oauth_nonce' => 'EF35F352-6FB0-4CFD-98E2-136BC6507434', 'oauth_version' => '1.0');
     $result = HTTP_OAuth::buildHTTPQuery($array);
     $this->assertEquals($result, 'oauth_consumer_key=e1nTvIGVCPkbfqZdIE7OyA&oauth_nonce=EF35F352-6FB0-4CFD-98E2-136BC6507434&oauth_signature=6WvHOHROOBkKcP3YrpnEHNbn1y4%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1245711961&oauth_token=kRmeTe0wvuIJrIUbjoOfc4UZcUerJKR67BfXy20UM&oauth_version=1.0');
 }