Twitter Bot : Post Qoutes to twitter automaticly via PHP
I made this code for my personal use but now thought of sharing this it over here.On execution this PHP will post a tweet in your profile via twitter api . Tweet will have a beautiful quote or saying.Set this PHP execution over a cron job or scheduled jobs.
<?php
echo realpath("twitter.php");
echo "<br>";
$type[0]="love";
$type[1]="friendship";
$type[2]="life";
$type[3]="funny";
$type[4]="inspirational";
$type[5]="money";
$type=$type[rand(0,5)];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://www.quotesdaddy.com/widget/tag/$type");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$q = curl_exec($curl);
curl_close($curl);
$q=explode("“",$q);
$q=explode("”",$q[1]);
$q=$q[0];
$username = '[username]';
$password = '[password]';
$status = urlencode(stripslashes(urldecode($q)));
if (
$status) {
$tweetUrl = 'http://www.twitter.com/statuses/update.xml';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "$tweetUrl");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status");
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
$result = curl_exec($curl);
$resultArray = curl_getinfo($curl);
if (
$resultArray['http_code'] == 200)
echo 'Tweet Posted';
else
echo 'Could not post Tweet to Twitter right now. Try again later.';
curl_close($curl);
}
?>
Shashank Amin 6:28 am on January 11, 2010 Permalink |
Oh now i came to know how does your status on onkut keeps on changing
Shashank Amin 6:28 am on January 11, 2010 Permalink |
orkut*
Shashank Amin 6:48 am on January 11, 2010 Permalink |
And could you share the script for orkut also please
chetanweb 12:00 pm on January 11, 2010 Permalink |
Thats something uniq about my profile !!
I dont want to make it common
Sorry
Shashank Amin 12:06 pm on January 11, 2010 Permalink |
OK
ace 9:52 am on January 11, 2010 Permalink |
nice thanks for the source…
Chetan 1:44 pm on January 21, 2010 Permalink |
I made one for facebook.com also will be posting soon
Shashank Amin 8:07 am on January 24, 2010 Permalink |
will be waiting