Archive for Tag "twitter"

Get User Timeline in PHP

//Simple php function to Get User Timeline

//implement
<?php
$arrTwet = Get_user_timeline("maulidi", 5);
foreach ( $arrTwet as $twet )
{
   echo "$twet\n";
}
?>

<?php
function Get_user_timeline($user, $limit)
{
    $url = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name=".urlencode($user)."&trim_user=true&count=".intval($limit);
    $json_data = json_decode(file_get_contents($url));
    
    $arrTwet = array();
    
    for($i=0; $i<=$limit; $i++)
    {
        if (isset( $json_data[$i] ))
        {
            $text = $json_data[$i]->text;
            $arrTwet[] = $text;
        }
    }
    
    return $arrTwet;
}
?>