A simple example:
function tweet($user,$pass,$app,$tweet)
{
$url = 'http://'.$user.':'.$pass.'@twitter.com/statuses/update.xml';
$post = http_build_query(array ('source' => $app, 'status' => $tweet));
$context = stream_context_create( array('http' => array('method' => 'POST', 'content' => $post)) );
$connection = @fopen($url, 'rb', false, $context);
if (!$connection) {
return false;
}
fclose($connection);
return true;
}
Usage Example:
tweet('username','password','tehuber','Hello World!');
source
share