
I found this tidbit on php.net. Super quick and easy tweet from within PHP courtesy of Fabien Potencier.
<?php
function tweet($message, $username, $password)
{
$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' => $message)),
'timeout' => 5,
),
));
$ret = file_get_contents('http://twitter.com/statuses/update.xml', false, $context);
return false !== $ret;
}
?>
Pretty easy, no? Using the tweet() function is of course a piece of cake:
<?php
tweet('From PHP, yeah...', 'fabpot', 'Pa$$');
?>New Blog Post! Gherkin - It Ain't Just a Pickle! http://t.co/diBtFADy
November 7, 2012
You built or have a site and now what? Usability testing! http://t.co/Qt8IX3NY Experiment, improve, repeat. We <3 usability!
October 18, 2012
Google Throws Open Doors to Its Top-Secret Data Center | Wired Enterprise | http://t.co/UoCR4op0 http://t.co/mnHXix2C -- we love this stuff!
October 17, 2012