I’ve been looking at it for a while and cannot figure out what the problem might be:
My Code:
<?php
session_start();
require "includes/config.php";
require "includes/database.php";
require "twitteroauth/twitteroauth.php";
if(empty(CONSUMER_KEY) && empty(CONSUMER_SECRET))
{
exit("Please define Consumer Key and Consumer Secret Keys");
}
$connection = new TwitterOAuth(CONSUMER_KEY,CONSUMER_SECRET);
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
// Temporary credentials to make requests to Twitter
$_SESSION["oauth_token"] = $request_token["oauth_token"];
$_SESSION["oauth_token_secret"] = $request_token["oauth_token_secret"];
switch ($connection->http_code)
{
case 200:
$url = $connection->getAuthorizeURL($request_token);
header("Location:".$url);
break;
default:
die("Connection to Twitter failed. Please try again.");
}
?>
And the error is:
##
Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in /home/.../connect.php on line 9
##
The line 9 part starts from
if(empty(CONSUMER_KEY) && empty(CONSUMER_SECRET))
{
exit("Please define Consumer Key and Consumer Secret Keys");
}
CONSUMER_KEY and CONSUMER_SECRET, they are constants and defined in “includes/config.php” like below:
$config = parse_ini_file("config.ini");
define("CONSUMER_KEY",$config["TwitterAPI"]["Consumer_Key"]);
define("CONSUMER_SECRET",$config["TwitterAPI"]["Consumer_Secret"]);
Use defined instead of
emptyto check if a constant exists.emptyandissetfunctions check if variables exist. If you’re wanting to check if it’s empty then just check the length.Very random that this exact error happened to me about 2 hours ago…