Monday, 27 July 2009 13:18
in this post i will show you how to get twitter info , updates , friends followers etc from certain user.
1- Twitter's user Main info
/************************Main info *************************/
$rssUrl = "http://twitter.com/users/show.xml?screen_name=$username";
$rss = @file_get_contents($rssUrl);
if($rss)
{
$xml = @simplexml_load_string($rss);
if($xml !== false)
{
// geting Twitter name
$name=$xml->name;
//geting twitter screen name
$screen_name=$xml->screen_name;
// user location
$location=$xml->location;
//user description
$description=$xml->description;
// link to user profile image
$profile_image_url=$xml->profile_image_url;
// user url as in the profile
$url=$xml->url;
// followers count
$followers_count=$xml->followers_count;
// friends count
$friends_count=$xml->friends_count;
// created date
$created_at=$xml->created_at;
// user favourites count
$favourites_count=$xml->favourites_count;
//user time zone
$time_zone=$xml->time_zone;
// updates count
$statuses_count=$xml->statuses_count;
//print_r($xml);
}
else
{
echo "Error: RSS file not valid!";
}
}
else
{
echo "Error: Username invalid or requires authentication";
}
/**************************************************************************************/
2- Twitter Friends Info
/*************************************Friends*************************************/
$rssUrl = "http://twitter.com/statuses/friends/$username.xml";
$rss = @file_get_contents($rssUrl);
if($rss)
{
$xml = @simplexml_load_string($rss);
if($xml !== false)
{
//print_r($xml);
foreach($xml->user as $tweet)
{
// geting friend's name
$f_name=$tweet->name;
// geting friend's screen name
$f_screen_name=$tweet->screen_name;
// link to friend's image
$f_profile_image_url=$tweet->profile_image_url;
}
}
else
{
echo "Error: RSS file not valid!";
}
}
else
{
echo "Username invalid or requires authentication";
}
/**************************************************************************************/
3- twitter Updates
/***************************updates ***************************************************/
$rssUrl = "http://twitter.com/statuses/user_timeline/$username.xml";
$rss = @file_get_contents($rssUrl);
if($rss)
{
$xml = @simplexml_load_string($rss);
if($xml !== false)
{
//print_r($xml->channel->item);
foreach($xml->status as $tweet)
{
// update id
$id=$tweet->id;
// update date
$created_at=$tweet->created_at;
// update text
$text=$tweet->text;
// update source ie: from web , from sharthis etc
$source=$tweet->source;
// update in replay to
$in_reply_to_screen_name=$tweet->in_reply_to_screen_name;
}
}
else
{
echo "Error: RSS file not valid!";
}
}
else
{
echo "Error:Username invalid or requires authentication";
}
/****************************************************************************************/
thats it for now . have fun : )

Thank you for sharing. There are many scripts and tools available on the internet that can allow you to integrate twitter on you r website or blog. However a lot of the times you need a simple solution that you can style or customise the code exactly to fit your needs. The examples you have listed here are great.
Click Here Web Design Every great business idea takes wings with the launch of a professionally designed website. e-commerce Ecommerce is an agile and trusted business solution.













