<?php /** * @author Roman Ozana <*****@*****.**> */ use twitter\TwitterApi; session_start(); require_once '../vendor/autoload.php'; $config = (require 'config.php'); if (isset($_REQUEST['oauth_token']) && $_SESSION['oauth_token'] !== $_REQUEST['oauth_token']) { $_SESSION['oauth_status'] = 'oldtoken'; header('Location: ./logout.php'); } /* Create TwitterApi object with app key/secret and token key/secret from default phase */ $connection = new TwitterApi($config->consumerKey, $config->consumerSecret, $_SESSION['oauth_token'], $_SESSION['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; /* Remove no longer needed request tokens */ unset($_SESSION['oauth_token']); unset($_SESSION['oauth_token_secret']); header('Location: ./index.php');