Hi,
I have problem with PHP code. The result shows exactly what I want but it enter to if statement regardless there is an error or not.
the output is attached
Can you help me to sole this problem, please?
[php]<?php
require_once(‘TwitterAPIExchange.php’);
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
‘oauth_access_token’ => “enterd code”,
‘oauth_access_token_secret’ => “enterd code”,
‘consumer_key’ => “enterd code”,
‘consumer_secret’ => “enterd code”
);
$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’])) {$count = $_GET[‘count’];} else {$count = 20;}
$getfield = “?screen_name=$user&count=$count”;
$twitter = new TwitterAPIExchange($settings);
$string = json_decode($twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(),$assoc = TRUE);
if($string[“errors”][0][“message”] != “”)
{echo “
Sorry, there was a problem.
Twitter returned the following error message:
”.$string[errors][0][“message”]."
";exit();}foreach($string as $items)
{
echo “Time and Date of Tweet: “.$items[‘created_at’].”
”;
echo “Tweet: “. $items[‘text’].”
”;
echo “Tweeted by: “. $items[‘user’][‘name’].”
”;
echo “Screen name: “. $items[‘user’][‘screen_name’].”
”;
echo “Followers: “. $items[‘user’][‘followers_count’].”
”;
echo “Friends: “. $items[‘user’][‘friends_count’].”
”;
echo “Listed: “. $items[‘user’][‘listed_count’].”
”;
}
?> [/php]