/** * Gets latest twitter status of selected user; Read XML file, cuts XML to the last twitter status only * Author: Tomasz Dobrzyński * Date: Thursday, 28 February 2008 08:30 [school? ;D] * copyright (C) 2008 by Tomasz Dobrzyński * license GNU General Public License version 2 http://www.gnu.org/licenses/old-licenses/gpl-2.0.html#SEC4 **/ function get_last_twitter($who) { /* CURL method */ $ch = curl_init ('http://twitter.com/statuses/user_timeline/'.$who.'.xml?count=1') ; curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ; $text = curl_exec ($ch) ; curl_close ($ch) ; //replacing special chars $text = str_replace ( '&', '&', $text ); $text = str_replace ( ''', '\'', $text ); $text = str_replace ( '"', '"', $text ); $text = str_replace ( '<', '<', $text ); $text = str_replace ( '>', '>', $text ); $table = explode("\n", $text); for($x=0; $x<=count($table); $x++) { //echo $table[$x]."\n"; $left_cut = strstr($table[$x], ''); if(strlen($left_cut)>0) { $obciety = NULL; for($y=0; $y<=strlen($left_cut); $y++) { $litera = $left_cut[$y]; if(($y>5) && ($y<(strlen($left_cut)-7) )) $obciety.=$left_cut[$y]; } return $obciety; } } } //shows result on screen echo get_last_twitter("TWITTER_USERNAME");