} header("Location: {$current_url}?function=error"); exit; } else { if ($_REQUEST['function'] == 'callback') { // You should set this route on your Twitter Application settings as the callback // https://apps.twitter.com/app/YOUR-APP-ID/settings if (isset($_SESSION['oauth_request_token'])) { $request_token = array('token' => $_SESSION['oauth_request_token'], 'secret' => $_SESSION['oauth_request_token_secret']); $api->reconfigure($request_token); $oauth_verifier = FALSE; if (isset($_REQUEST['oauth_verifier'])) { $oauth_verifier = $_REQUEST['oauth_verifier']; } // get_access_token() will reset the token for you $token = $api->get_access_token($oauth_verifier); if (!isset($token['oauth_token_secret'])) { header("Location: {$current_url}?function=error&error=" . urlencode(print_r($token, TRUE))); exit; } } $credentials = $api->get('account/verify_credentials'); if (is_array($credentials) && !isset($credentials['errors'])) { // $credentials contains the Twitter user object with all the info about the user. // Add here your own user logic, store profiles, create new users on your tables...you name it! // Typically you'll want to store at least, user id, name and access tokens // if you want to be able to call the API on behalf of your users. // This is also the moment to log in your users echo "Congrats! You've successfully signed in!<br/>"; echo "This is your user object:<br/>"; print_r($credentials);