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: [...]