If you're working with twitter, you should consider using the Twitter.php class. It's very easy to use and intuitive
Here's an example of how I used Twitter.php in a module I wrote:
try {
$username = 'useername';
$password = 'password';
$twi_user = new Twitter($username,$password);
$user_text = 'hello world';
$twi_user->updateStatus($user_text);
}
catch (Exception $e) {
echo $e->getMessage();
}
OR Try and see if an error is caught:
try {
$rss = simplexml_load_file("http://search.twitter.com/search.atom?lang=en&q=charlton&rpp=100&page=1");
foreach($rss->entry as $item){
$title = $item->title;
print "$title";
}
}
catch (Exception $e) {
echo $e->getMessage()
}