本文實例講述了php獲取twitter最新消息的方法。分享給大家供大家參考。具體實現方法如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 <?php function get_status($twitter_id, $hyperlinks = true) { $c = curl_init(); curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$twitter_id.xml?count=1"); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); $src = curl_exec($c); curl_close($c); preg_match('/<text>(.*)</text>/', $src, $m); $status = htmlentities($m[1]); if( $hyperlinks ) $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href="