pversion; |
} |
public function loadTimeline($user, $max = 20 ){ |
$ this ->twitURL .= 'statuses/user_timeline.xml?screen_name=' .$user. '&count=' .$max; |
$ch = curl_init(); |
curl_setopt($ch, CURLOPT_URL, $ this ->twitURL); |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); |
$ this ->xml = curl_exec($ch); |
return $ this ; |
} |
public function getTweets(){ |
$ this ->twitterArr = $ this ->getTimelineArray(); |
$tweets = array(); |
foreach($ this ->twitterArr->status as $status){ |
$tweets[$status->created_at->__toString()] = $status->text->__toString(); |
} |
return $tweets; |
} |
public function getTimelineArray(){ |
return simplexml_load_string($ this ->xml); |
} |
public function formatTweet($tweet){ |
$tweet = preg_replace( "/(http(.+?))( |$)/" , "$1$3" , $tweet); |
$tweet = preg_replace( "/#(.+?)(\h|\W|$)/" , "#$1$2" , $tweet); |
$tweet = preg_replace( "/@(.+?)(\h|\W|$)/" , "@$1$2" , $tweet); |
return $tweet; |
} |
} |