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 = $parameters ? $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 function authUser()
 {
     $test_consumer = new OAuthConsumer($this->config['key'], $this->config['secret'], NULL);
     $sig_method = new OAuthSignatureHMACSHA1();
     $parsed = parse_url($this->config['reqtoken']);
     $params = array('callback' => $this->config['callbase']);
     parse_str($parsed['query'], $params);
     $req_req = OAuthRequest::from_consumer_and_token($test_consumer, NULL, "GET", $this->config['reqtoken'], array('callback' => $this->config['callbase']));
     $req_req->sign_request($sig_method, $test_consumer, NULL);
     $req_token = $this->request->doRequest($req_req->to_url());
     parse_str($req_token, $tokens);
     $oauth_token = $tokens['oauth_token'];
     $oauth_token_secret = $tokens['oauth_token_secret'];
     $callback_url = "{$this->config['callbase']}?key={$this->config['key']}&token={$oauth_token}&token_secret={$oauth_token_secret}&endpoint=" . urlencode($this->config['authorize']);
     $auth_url = $this->config['authorize'] . "?oauth_token={$oauth_token}&oauth_callback={$callback_url}";
     Header("Location: {$auth_url}");
 }