Automatic Twitter status update - tweet script or cron job

Hi, I need a script that would run as a cron job every 30-40 minutes and post automatic tweets about 20-40 different default tweets so that it can repeat. Can anyone here create such script? Thanks!

Hi there. Here is the function that you can use to submit tweets to your twitter account:

[php]

<?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; } ?>

[/php]

To use this function, create file named for example post_tweet_to_twitter.php
In that file place the code above and call the function as shown below:

[php]

<?php tweet('Tweet tweet tweet...', 'your_twitter_account', 'your_passw'); ?>

[/php]

You can add a task to your cron manager and set it up to run on required intervals. The command would be like shown below (using Lynx browser):

lynx -source http://www.yourwebsite.com/post_tweet_to_twitter.php > /dev/null
Sponsor our Newsletter | Privacy Policy | Terms of Service