I am building a Twitter client w/ php and am receiving this error message when I try to run the program. It seems something to do with the server when I run it locally? I have php instlled. I am using Aptana as my IDE. What is the issue?
$url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
$requestMethod = "GET";
if (isset($_GET['user'])) {$user = $_GET['user'];} else {$user = "hello";}
if (isset($_GET['count'])) {$count = $_GET['count'];} else {$count = 20;}
$getfield = '?screen_name=hello&count=20';
$twitter = new TwitterAPIExchange($settings);
$string = json_decode(
$twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(), $assoc = TRUE
);
if($string["errors"][0]["message"] != "") {
echo "<h3>Sorry, there was a problem.</h3><p>Twitter returned the following error message:</p><p><em>" . $string[errors][0]["message"] . "</em></p>";
exit();
}
foreach($string as $items) {
echo "Time and Date of Tweet: ".$items['created_at']."<br />";
echo "Tweet: ". $items['text']."<br />";
echo "Tweeted by: ". $items['user']['name']."<br />";
echo "Screen name: ". $items['user']['screen_name']."<br />";
echo "Followers: ". $items['user']['followers_count']."<br />";
echo "Friends: ". $items['user']['friends_count']."<br />";
echo "Listed: ". $items['user']['listed_count']."<br /><hr />";
}
?>
error message:
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']."
error message in view source format:
<?php
require_once('TwitterAPIExchange.php");
$settings = array(
'oauth_access...
);
$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=iagdotme&count=20';
$twitter = new TwitterAPIExchange($settings);
$string = json_decode($twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(),$assoc = TRUE);
if($string["errors"][0]["message"] != "") {echo "<h3>Sorry, there was a problem.</h3>
<p>Twitter returned the following error message:</p><p><em>".$string[errors][0]["message"].
"</em></p>";exit();}
foreach($string as $items)
{
echo "Time and Date of Tweet: ".$items['created_at']."<br />";
echo "Tweet: ". $items['text']."<br />";
echo "Tweeted by: ". $items['user']['name']."<br />";
echo "Screen name: ". $items['user']['screen_name']."<br />";
echo "Followers: ". $items['user']['followers_count']."<br />";
echo "Friends: ". $items['user']['friends_count']."<br />";
echo "Listed: ". $items['user']['listed_count']."<br /><hr />";
}
?>
there is a note that says: Saw "<?
". Probable cause: Attempt to use an XML processing instruction in HTML. (XML processing instructions are not supported in HTML.)
here is the tutorial I am following: https://iag.me/socialmedia/build-your-first-twitter-app-using-php-in-8-easy-steps/