Example #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 or $parameters = array();
     $defaults = array("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);
 }
Example #2
0
 public static function setAuth($_url, $_method = 'GET')
 {
     $consumer = new OAuthConsumer('', '');
     $token = new OAuthToken(Vzaar::$secret, Vzaar::$token);
     $req = OAuthRequest::from_consumer_and_token($consumer, $token, $_method, $_url);
     $req->set_parameter('oauth_signature_method', 'HMAC-SHA1');
     $req->set_parameter('oauth_signature', $req->build_signature(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, $token));
     return $req;
 }