public function callBack()
{
/* If the oauth_token is old redirect to the connect page. */
// if (isset($_REQUEST['oauth_token']) && $_SESSION['oauth_token'] !== $_REQUEST['oauth_token'])
if (isset($_REQUEST['oauth_token']) && $this->session->userdata('oauth_token') !== $_REQUEST['oauth_token']) {
// $_SESSION['oauth_status'] = 'oldtoken';
// header('Location: ./clearsessions.php');
echo "bad oauth_token";
return false;
}
/* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
$connection = new TwitterOAuth(_TWITTER_CONSUMER_KEY_, _TWITTER_CONSUMER_SECRET_, $this->session->userdata('oauth_token'), $this->session->userdata('oauth_token_secret'));
/* Request access tokens from twitter */
$access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
/* Save the access tokens. Normally these would be saved in a database for future use. */
$_SESSION['access_token'] = $access_token;
$this->db_update("users", $access_token, array("id" => $this->session->userdata('id')));
// /* Remove no longer needed request tokens */
// unset($_SESSION['oauth_token']);
// unset($_SESSION['oauth_token_secret']);
/* If HTTP response is 200 continue otherwise send to connect page to retry */
if (200 == $connection->http_code) {
/* The user has been verified and the access tokens can be saved for future use */
// $_SESSION['status'] = 'verified';
// header('Location: ./index.php');
echo "TWITTER OK";
} else {
/* Save HTTP status for error dialog on connnect page.*/
// header('Location: ./clearsessions.php');
echo "ERROR";
}
}