<?php
$twitter_id = 'espncricinfo';
$number_of_tweets = 4;


function linkable($text = ''){
    $text = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $text));
    $data = '';
    foreach( explode(' ', $text) as $str){
        if (preg_match('#^http?#i', trim($str)) || preg_match('#^www.?#i', trim($str))) {
            $data .= '<a href="'.$str.'">'.$str.'</a> ';
        } else {
            $data .= $str .' ';
        }
    }
    return trim($data);
}

?>
<div style="margin: auto; width:350px; border: 10px solid rgb(177, 212, 252); border-radius: 10px 10px 10px 10px;" id="twitter_lf">
    <div class="twitterSearchTitle" style="background-color: rgb(177, 212, 252); margin: 0px; padding: 0px 0px 5px; text-align: center; font-weight: bold; font-size: large; position: relative;">
        <a href="http://twitter.com/abiosystems" style="text-decoration: none; color: rgb(59, 89, 152);">
        @<?php echo $twitter_id;?> <br /> <span style="font-size:10px;">Live Twitter Feed</span></a><a href="http://www.twitter.com">
        <img src="http://cloud.github.com/downloads/malsup/twitter/tweet.gif" class="twitterSearchBird" style="width: 50px; height: 20px; position: absolute; left: -30px; top: -20px; border: medium none;">
        </a>
    </div>
    
    <div class="twitterSearchContainter" style="overflow: hidden; background-color: rgb(255, 255, 255); height: auto; display: block;">
    <?php 
    //by dharam to get twitter feed
    $responseJson = file_get_contents('http://api.twitter.com/1/statuses/user_timeline.json?screen_name='.$twitter_id.'&include_rts=1&count='.$number_of_tweets);
    if($responseJson) {
        $responseAray = json_decode($responseJson);
        foreach($responseAray as $resp) {
            ?>
            <div style="padding:3px; margin:0 0 2px 0;">
            <a style="color:#00BEF2;" href="https://twitter.com/intent/user?screen_name=abiosystems" target="_blank">@<?php echo $resp->user->screen_name;?></a> <?php echo linkable($resp->text);?><br />
            <a style="color:#0E313B;" href="https://twitter.com/intent/tweet?in_reply_to=<?php echo $resp->id_str;?>">reply</a> | 
            <a style="color:#0E313B;" href="https://twitter.com/intent/retweet?tweet_id=<?php echo $resp->id_str;?>">retweet</a> | 
            <a style="color:#0E313B;" href="https://twitter.com/intent/favorite?tweet_id=<?php echo $resp->id_str;?>">favorite</a>
            </div>
            <?php
        }
    }
    ?>
    </div>
</div>