php: Fetch public user tweets
<?php
// Functions to fetch public tweets of any user
// Let's update this
function get_tweets($screen_name = 'vinnizworld'){
$api_url = "https://api.twitter.com/1/statuses/user_timeline.json";
$feed = $api_url."?screen_name=".$screen_name."&limit=20";
$headers = get_headers($feed);
$tweets = array();
if (!strpos($headers[0], '200')) {
return false;
}
else{
$a = json_decode(file_get_contents($feed));
foreach($a as $status){
$tweet['status'] = $status->text;
$tweet['posted_on'] = date("Y-m-d h:m:s",strtotime($status->created_at));
array_push($tweets,$tweet);
}
return $tweets;
}
}