<?php
$count=30;
$login = "username:password"; //your twitter id/pass
$url = "http://twitter.com/statuses/friends_timeline.xml?count=$count";

$twt = curl_init();
curl_setopt($twt, CURLOPT_URL, $url);
curl_setopt($twt, CURLOPT_USERPWD, $login);
curl_setopt($twt, CURLOPT_RETURNTRANSFER, TRUE);
$twi = curl_exec($twt);

$twitter = new SimpleXMLElement($twi);
$latesttweets = count($twitter);

?>
<html>
<head>
<? header( 'refresh: 180; url='.$PHP_SELF.'?'.date("YmdHis") ); ?>
<style>
.user, .name, .followers, .location, .text { font-size: 13px;color:#666666; font-family: Tahoma, "Lucida Grande";}
.textfrom, .textfrom a:link,a:visited  { font-size: 11px;color:#003366;}
.textfrom a:hover { color: #FF4B33; }
.name { font-size: 11px;color:#666666; font-family: Tahoma, "Lucida Grande";}
.headline { display: block; padding-bottom: 20px;}
a:link {  color:#666666; }
a:visited { color:#666666;}
a:active, a:hover { color: #FF4B33; }
</style>
</head>
<body>
<?php
foreach ($twitter->status as $twit1) {

$description = $twit1->text;
$description = preg_replace("#(^|[\n ])@([^ \"\t\n\r<]*)#ise", "'\\1<a target=\"_blank\" href=\"http://www.twitter.com/\\2\" >@\\2</a>'", $description);
$description = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", "'\\1<a target=\"_blank\" href=\"\\2\" >\\2</a>'", $description);
$description = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#ise", "'\\1<a target=\"_blank\" href=\"http://\\2\" >\\2</a>'", $description);
$description = addemo($description); //เปลี่ยน emo-text เป็น emoticon
echo "<div class='headline'><a href=\"http://www.twitter.com/", $twit1->user->screen_name,"\" target=\"_blank\"><img align='left' border=\"0\" src=\"", $twit1->user->profile_image_url, "\" title=\"", $twit1->name, "\" /></a>\n";
echo "<div class='text'>".$description."</div>";
echo "<div class='textfrom'><a href=\"http://twitter.com/", $twit1->user->screen_name,"\" target=\"_blank\">โดย: ", $twit1->user->name,"</a></div>";
if (strlen(chop($twit1->user->location))!=0) echo "<div class='textfrom'>ที่อยู่: ",$twit1->user->location,"</div>";
echo "</div>";
} // end for_each
curl_close($twt);

?>
</body>
</html>
<?php
function addemo($str) {
$text=array(
0 => '/:-\)/',
1 => '/:\)/',
2 => '/:-\(/',
3 => '/:\(/',
4 => '/:\'\(/',
5 => '/:p/',
6 => '/:P/',
7 => '/:d/',
8 => '/:D/',
9 => '/sad/',
10 => '/very sad/',
11 => '/cry/'
);
$icon=array(
0 => '<img src=http://pladao.net/images/icons/smile.gif>',
1 => '<img src=http://pladao.net/images/icons/smile.gif>',
2 => '<img src=http://pladao.net/images/icons/sad.gif>',
3 => '<img src=http://pladao.net/images/icons/sad.gif>',
4 => '<img src=http://pladao.net/images/icons/cry.gif>',
5 => '<img src=http://pladao.net/images/icons/toungout.gif>',
6 => '<img src=http://pladao.net/images/icons/toungout.gif>',
7 => '<img src=http://pladao.net/images/icons/laugh.gif>',
8 => '<img src=http://pladao.net/images/icons/laugh.gif>',
9 => '<img src=http://pladao.net/images/icons/sad.gif>',
10 => '<img src=http://pladao.net/images/icons/sad.gif>',
11 => '<img src=http://pladao.net/images/icons/cry.gif>'
);
$str = preg_replace($text,$icon,$str);
return $str;
}

?>