I am using twitter API v1.1 to get tweets in my web application the code for getting tweets is as
$name = 'zkalvi';
$url = "https://api.twitter.com/1.1/search/tweets.json/".$name;
$tweets = json_decode(file_get_contents($url));
echo '<ul>';
foreach($tweets as $tweet) {
echo '<li>'.$tweet->text.'</li>';
and
}
echo '</ul>';$name = 'zkalvi';
$url = "https://api.twitter.com/1.1/search/tweets.json/".$name;
$tweets = simplexml_load_file($url);
echo '<ul>';
foreach($tweets as $tweet) {
echo '<li>'.$tweet->text.'</li>';
}
echo '</ul>';
both of these codes are not showing the tweets.
Please help me why the tweets are not showing and how could I show the tweets?
Thanks in advance.
first of all, the way you are calling is wrong, your url should be like this https://api.twitter.com/1.1/search/tweets.json?q=zkalvi.
By this url you will get following output
{"errors":[{"message":"Bad Authentication data","code":215}]}
This is because , in twitter 1.1 version, most of thing needs authentication. So better you use twitter server side library for getting results.
Here is link for twitteroauth library for php twitteroauth