· 9 years ago · Sep 18, 2016, 01:42 AM
1// Request a token and redirect to the authorization page
2$token = $this->twitter->getRequestToken();
3
4// Set the session data
5$this->session->set_userdata('oauth_token', $token['oauth_token']);
6$this->session->set_userdata('oauth_token_secret', $token['oauth_token_secret']);
7
8// Redirect the user to the authorization page
9header('Location: https://api.twitter.com/oauth/authorize?oauth_token='.$token['oauth_token']);
10
11// Get the parameters from the URL
12$token = $this->input->get('oauth_token');
13$verifier = $this->input->get('oauth_verifier');
14
15$oauthToken = $this->session->oauth_token;
16$oauthSecret = $this->session->oauth_token_secret;
17
18// Get the access token
19$access = $this->twitter->getAccessToken($verifier, $oauthToken, $oauthSecret);