Esempio n. 1
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 = $parameters ? $parameters : [];
     $defaults = ["oauth_version" => OAuthRequest::$version, "oauth_nonce" => OAuthRequest::generate_nonce(), "oauth_timestamp" => OAuthRequest::generate_timestamp(), "oauth_consumer_key" => $consumer->key];
     if ($token) {
         $defaults['oauth_token'] = $token->key;
     }
     $parameters = array_merge($defaults, $parameters);
     return new OAuthRequest($http_method, $http_url, $parameters);
 }
Esempio n. 2
0
 /**
  * Make signed request
  */
 public function signedRequest($url, $method, $parameters)
 {
     $request = 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->request($request->to_url(), 'GET');
         default:
             return $this->request($request->get_normalized_http_url(), $method, $request->to_postdata(), $request->to_header());
     }
 }