Use following code to get profile of a twitter user. You need to pass the username as an arguement in profileXML method, which returns the associative array of user’s profile information.

<?php

function profileXML($user)

           {

$objDOM = new DOMDocument();

$objDOM->load("http://api.twitter.com/1/users/show.xml?screen_name=".$user);

$note = $objDOM->getElementsByTagName("user");

foreach($note as $value )

       {

$id = $value->getElementsByTagName("id");

$id  = $id->item(0)->nodeValue;

$profile["id"]=$id;

                       

$name = $value->getElementsByTagName("name");

$name  =$name->item(0)->nodeValue;

$profile["name"]=$name;

             

$screen_name = $value->getElementsByTagName("screen_name");

$screen_name  =$screen_name->item(0)->nodeValue;

$profile["screen_name"]=$screen_name;

                       

$followers = $value->getElementsByTagName("followers_count");

$followers  =$followers->item(0)->nodeValue;

$profile["followers"]=$followers;

                       

$friends = $value->getElementsByTagName("friends_count");

$friends  =$friends->item(0)->nodeValue;

$profile["friends"]=$friends;

                       

$location = $value->getElementsByTagName("location");

$location  =$location->item(0)->nodeValue;

$profile["location"]=$location;

$description = $value->getElementsByTagName("description");

$description  =$description->item(0)->nodeValue;

$profile["description"]=$description;

                       

$profile_image_url = $value->getElementsByTagName("profile_image_url");

$profile_image_url  =$profile_image_url->item(0)->nodeValue;

$profile["profile_image_url"]=$profile_image_url;

}    

 

return $profile;

 

}

//Pass username as parameter

print_r(profileXML("barackobama"));

 

?>