Tags
I know this one is old thing and helps is available but sometime we need to fetch twitter feeds Retwittet, Mentions, to our websites. Now i used json request and format the texts and print.
function twi_fid(){ ## NUMBER OF TWITTET $size = 5; ## FETCH THE TWITTER TWITTET $twittet = file_get_contents("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=bdsarwar&count=$size&include_rts=t&include_entities=t"); $data = json_decode($twittet); $o_text = ""; foreach($data as $t) { $o_text = $t->text; ## MAKING URLS ENABLE TO TEXT $entities = $t->entities; $i = 0; foreach($entities->urls as $url) { $indicate = $url->indices; $replace[$i] = $url->url; $string[$i] = "<a target='_blank' href='".$url->url."'>".$url->url."</a>"; $i++; } ## MAKING MENTIONS foreach($entities->user_mentions as $mention) { $indicate = $mention->indices; $string[$i] = "<a target='_blank' href='http://www.twitter.com/".$mention->screen_name."'>".$mention->screen_name."</a>"; $replace[$i] = $mention->screen_name; $i++; } for($i = 0; $i < count($string); $i++) { $pattarn = $replace[$i]; $o_text = str_replace($pattarn, $string[$i], $o_text); } echo $o_text; echo "<br />"; echo date("d/m/Y, H:m a", strtotime($t->created_at)); echo "<br/> ___ <br />"; } } twi_fid();
For detail parameter please visit: http://apiwiki.twitter.com/w/page/22554679/Twitter-API-Documentation
and for user timeline json visit http://dev.twitter.com/doc/get/statuses/user_timeline
Done !!
hi
thanks for this script
working very well,
but i have a question?
is there any limit to access data my mean to hit a URL .
is there any limit to hit a URL on twitter in one day or month.
hope u can understand what i am asking you.
thanks
Dear Sarwar,
thanx very useful.. but how to use this for twitter user with privacy..
i got an error like this
Warning: file_get_contents(http://api.twitter.com/1/statuses/user_timeline.json?screen_name=fecasaid&count=5&include_rts=t&include_entities=t) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 401 Unauthorized
please help me.. 😥 thanx u very much