I wrote a post about using file_get_contents() in PHP with context stream a while ago. I thought I’d post a usage example. Below is a function that posts your message into your twitter profile directly from PHP.

function myTweet($username, $password, $msg)
$context = stream_context_create(array(
'http' =>  array(
'method'  =>  'POST',
'header'  =>  sprintf("Authorization: Basic %s\r\n", base64_encode($username.':'.$password)).
"Content-type:  application/x-www-form-urlencoded\r\n",
'content' =>  http_build_query(array('status' => $msg)),
'timeout' =>  5,
$ret = file_get_contents('<a rel="nofollow" href="http://twitter.com/statuses/update.xml" target="_blank">http://twitter.com/statuses/update.xml</a>', false, $context);

return false !==  $ret;

Function usage:

if(myTweet("I am finally home", "myuser", "mypass")</code>)
echo 'Tweet posted!';
echo 'Error posting tweet!';