How to use Twitter APIs with PHP


#1

Hi,

I am new to the twitter apis. I just want to use a simple api.
I came across the following code:
require_once(‘TwitterAPIExchange.php’);
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
‘oauth_access_token’ => “Access_Token”,
‘oauth_access_token_secret’ => “Access_Token_Secret”,
‘consumer_key’ => “API_KEY”,
‘consumer_secret’ => “API_SECRET”
);
$url = “https://api.twitter.com/1.1/statuses/user_timeline.json”;
$requestMethod = “GET”;
if (isset($_GET[‘user’])) {$user = $_GET[‘user’];} else {$user = “iagdotme”;}
if (isset($_GET[‘count’])) {$user = $_GET[‘count’];} else {$count = 20;}
$getfield = “?screen_name=$user&count=$count”;
$twitter = new Common_Class_TwitterAPIExchange($settings);
$string = json_decode($twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(),$assoc = TRUE);

	return $string;

I created a app and got the API Keys and Access Tokens.
When I run this code, I just receive an empty response. The $string variable is null.

Any ideas?
Regards
Hareendra