I have set up an AWS instance with a LAMP stack and am trying to build a simple login with Twitter button using Abraham's TwitterOAuth (https://twitteroauth.com/redirect.php).
I've set up the config.php file to have the key, secret, and callback url that match the apps.twitter.com details. Here is my login.php file:
<?php
require "twitteroauth/autoload.php";
echo "require<br>";
use Abraham\TwitterOAuth\TwitterOAuth;
echo "use <br>";
session_start();
echo"session started <br>";
define('CONSUMER_KEY', getenv('CONSUMER_KEY'));
define('CONSUMER_SECRET', getenv('CONSUMER_SECRET'));
define('OAUTH_CALLBACK', getenv('OAUTH_CALLBACK'));
echo"vars defined <br>";
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret);
//$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
echo "connection established <br>";
echo OAUTH_CALLBACK;
$request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => OAUTH_CALLBACK));
echo "token requested<br>";
$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
$url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
?>
All the echoes work up until $request_token at which point it breaks. I've also tried without the echoes, but it still doesn't make it to the redirect step. Any help would be greatly appreciated! Thank you.
Was able to figure out that I had the key, secret and callback defined incorrectly at the top. Needed to use the variable name $CONSUMER_KEY instead of the environmental name.