Advertisement
kotvalera83

TwitterOAuth

Jan 21st, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1.     public function twitter()
  2.     {
  3.         // The TwitterOAuth instance
  4.  
  5.         $twitteroauth = new TwitterOAuth($this->config->item('key', 'twitter'), $this->config->item('secret', 'twitter'));
  6.         // Requesting authentication tokens, the parameter is the URL we will be redirected to
  7.         $request_token = $twitteroauth->getRequestToken( site_url() . 'auth/twitter_oauth' );
  8.  
  9.         // Saving them into the session
  10.         $array = array(
  11.             'oauth_token' => $request_token['oauth_token'],
  12.             'oauth_token_secret' => $request_token['oauth_token_secret']
  13.         );
  14.        
  15.         $this->session->set_userdata( $array );
  16.  
  17.         // If everything goes well..
  18.         if($twitteroauth->http_code==200){
  19.             // Let's generate the URL and redirect
  20.             $url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']);
  21.             header('Location: '. $url);
  22.         } else {
  23.             // It's a bad idea to kill the script, but we've got to know when there's an error.
  24.             die('Something wrong happened.');
  25.         }
  26.  
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement