<p>User Token: <?php echo htmlspecialchars($oauth_creds['oauth_token']) ?><br />
            	User Secret: <?php echo htmlspecialchars($oauth_creds['oauth_token_secret']) ?></p>
            	<?php*/
        }
        return false;
    }
    $params = uri_params();
    if (!isset($params['oauth_token'])) {
        // Step 1: Request a temporary token and
        // Step 2: Direct the user to the authorize web page
        request_token($tmhOAuth);
    } else {
        // Step 3: This is the code that runs when Twitter redirects the user to the callback. Exchange the temporary token for a permanent access token
        $oauth_creds = access_token($tmhOAuth);
        if ($oauth_creds && isset($oauth_creds['oauth_token']) && !empty($oauth_creds['oauth_token']) && isset($oauth_creds['oauth_token_secret']) && !empty($oauth_creds['oauth_token_secret'])) {
            // yay we're connected to twitter!
            // write these to the database so we can do stuff on the backend.
            $twitter_account->update('twitter_name', $oauth_creds['screen_name']);
            $twitter_account->update('twitter_id', $oauth_creds['user_id']);
            $twitter_account->update('user_key', $oauth_creds['oauth_token']);
            $twitter_account->update('user_secret', $oauth_creds['oauth_token_secret']);
            $twitter_account->update('last_checked', time());
            set_message('Successfully connected to Twitter');
            redirect_browser(module_social_twitter::link_open($social_twitter_id));
        } else {
            echo 'Failed to connect to twitter';
            echo $tmhOAuth->response['response'];
        }
    }
}