Exemplo n.º 1
0
 /**
  * Format and sign an OAuth / API request
  */
 function oAuthRequest($url, $method, $parameters)
 {
     if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
         $url = "{$this->host}{$url}.{$this->format}";
     }
     $request = Converio_OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
     $request->sign_request($this->sha1_method, $this->consumer, $this->token);
     switch ($method) {
         case 'GET':
             return $this->http($request->to_url(), 'GET');
         default:
             return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
     }
 }
Exemplo n.º 2
0
 /**
  * pretty much a helper function to set up the request
  */
 public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters = NULL)
 {
     @$parameters or $parameters = array();
     $defaults = array("oauth_version" => Converio_OAuthRequest::$version, "oauth_nonce" => Converio_OAuthRequest::generate_nonce(), "oauth_timestamp" => Converio_OAuthRequest::generate_timestamp(), "oauth_consumer_key" => $consumer->key);
     if ($token) {
         $defaults['oauth_token'] = $token->key;
     }
     $parameters = array_merge($defaults, $parameters);
     return new Converio_OAuthRequest($http_method, $http_url, $parameters);
 }