// 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); exit; } var_dump('Crab! Something went wrong while signing you up!'); exit; } elseif ($_REQUEST['function'] == 'error') { // Handle the possible error
<?php require_once dirname(__DIR__) . '/vendor/autoload.php'; // Autoload files using Composer autoload use j3j5\TwitterApio; $api = new TwitterApio(); $result = $api->get('account/verify_credentials'); if (isset($result['id'])) { echo "Your user @{$result['screen_name']} has ID '{$result['id']}' and name '{$result['name']}'." . PHP_EOL; } else { $config_path = dirname(__DIR__) . "/src/j3j5/config.php"; echo "An error occured, did you fill the config.php file?" . PHP_EOL; echo "It should be on {$config_path}" . PHP_EOL; } return;