Пример #1
0
 /**
  * Used to generate the access tokens from Twitter.  This is the last step in the authentication process
  *
  * @param string $settings
  * @return boolean : depending if we were able to generate the tokens and save them to the DB or NOT
  * @author Bryant Hughes
  */
 private function generate_access_tokens($settings)
 {
     $this->EE->load->model('twitter_model');
     //Retrieve our previously generated request token & secret
     $requestToken = $settings['request_token'];
     $requestTokenSecret = $settings['request_token_secret'];
     $oauth = new TwitterEETwitter_OAuth('consumer_key', 'consumer_secret', $requestToken, $requestTokenSecret);
     // Generate access token by providing PIN for Twitter
     $request = $oauth->getAccessToken(NULL, $settings['pin']);
     if ($request != FALSE) {
         $access_token = $request['oauth_token'];
         $access_token_secret = $request['oauth_token_secret'];
         // Save our access token/secret
         return $this->EE->twitter_model->insert_access_token($access_token, $access_token_secret);
     } else {
         return FALSE;
     }
 }
Пример #2
0
 /**
  * curl Fetch
  *
  * Fetch Twitter statuses using cURL
  *
  * @access	public
  * @param	string
  * @return	string
  */
 function _curl_fetch($url, $params)
 {
     $data = '';
     //this is where we have modified the plugin to fetch our data via oauth
     $this->EE->load->model('twitter_model');
     $settings = $this->EE->twitter_model->get_settings();
     // Read in our saved access token/secret
     $access_token = $settings['access_token'];
     $access_token_secret = $settings['access_token_secret'];
     // Create our twitter API object
     $oauth = new TwitterEETwitter_OAuth($settings['consumer_key'], $settings['consumer_secret'], $access_token, $access_token_secret);
     $oauth->decode_json = FALSE;
     $data = $oauth->get($url, $params);
     return $data;
 }