Beispiel #1
0
 /**
  * @param unknown_type $consumer
  * @param unknown_type $token
  * @param unknown_type $http_method
  * @param unknown_type $http_url
  * @param unknown_type $parameters
  * @return JO_OAuth_Request
  */
 public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters = NULL)
 {
     @$parameters or $parameters = array();
     $defaults = array("oauth_version" => JO_OAuth_Request::$version, "oauth_nonce" => JO_OAuth_Request::generate_nonce(), "oauth_timestamp" => JO_OAuth_Request::generate_timestamp(), "oauth_consumer_key" => $consumer->key);
     if ($token) {
         $defaults['oauth_token'] = $token->key;
     }
     $parameters = array_merge($defaults, $parameters);
     return new JO_OAuth_Request($http_method, $http_url, $parameters);
 }
Beispiel #2
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 = JO_OAuth_Request::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());
     }
 }