Пример #1
0
 public function redirectTwitter()
 {
     $tokens = Twitter::oAuthRequestToken();
     Twitter::oAuthAuthenticate(array_get($tokens, 'oauth_token'));
     exit;
 }
Пример #2
0
 /**
  * Login
  * 
  * Logs into Twitter 
  */
 public function login()
 {
     $CI =& get_instance();
     $user_id = $CI->tank_auth->get_user_id();
     $CI->load->model('user_accounts_model');
     // Make sure that existing account is not primary first
     $accounts = $CI->user_accounts_model->get_by_user_id($user_id, 'TWITTER', NULL, true);
     $account = count($accounts) > 0 ? $accounts[0] : NULL;
     if ($account) {
         $CI->user_accounts_model->update($account->id, array('is_primary' => 0));
     }
     // Reqest tokens
     $tokens = null;
     $tries = 0;
     try {
         $tokens = Twitter::oAuthRequestToken();
     } catch (Exception $e) {
         // Refresh page
         syslog(LOG_WARNING, 'Invalid oAuth credentials, refreshing page');
         header('location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
         exit;
     }
     // Redirect to twitter
     Twitter::oAuthAuthenticate($tokens['oauth_token']);
 }