Update Your Twitter Status programmatically Using Twitter Basic Authentication With PHP
It is very easy to programmatically update your twitter status using PHP. Here is the ready to use code that can be used to make auto-tweet; may be you can write the custom code that fetches random blog post from your blog and tweet it on your twitter. It is currently making use of twitter basic authentication. It is good to use OAUTH. However, this basic authentication is still valid.
$username = ‘twitterusername’;
$password = ‘twitterpassword’;
$format = ‘xml’; //alternative: json
$message = $message . urlencode($url);
$result = shell_exec(‘curl http://twitter.com/statuses/update.’.$format.’ -u ‘.$username.’:’.$password.’ -d status=”‘.str_replace(‘”‘,’\”‘,$message).’”‘);
echo $result;
















Mayur Gondaliya
As of 16th August 2010, the basic authentication is no longer supported. Use OAUTH instead of basic authentication.