In this post I discuss making auto tweet twitter bot with PHP. In this case you also update your tweet without login to your twitter accout, bot is just to update the tweet so scheduled.
First create apps on twitter here to get a consumer key, consumer secret, the user token and user secret. then download twitter library of the mat harris here then extract the htdocs folder and then rename it Tweetbot.
Create a file tweet.php, for the contents of my tweets using arrays like this bellow:
Then create a file whose contents count.txt useful to be variable repetition. The contents of the file are only numbers. I use to run php cli. how to run it:
psychology @ cmyk : ~ $ php /opt/lampp/htdocs/tweetbot/tweet.php
Note : psychology is the name of your username website
Then to the transfers could use crontab, my example will run every hour, on the cronjob on your CPanel :
* 1 * * * php /opt/lampp/htdocs/tweetbot/tweet.php
Perhaps more friends can develop it further in order to become more attractive as possible by using mysql to tweet or other contents.
Download FULL SOURCE HERE
Create a file tweet.php, for the contents of my tweets using arrays like this bellow:
>'tweet pertama', 2 =>'tweet kedua', 3 =>'tweet ketiga', );
$f = fopen('data.txt', 'r');
$i = fscanf($f, '%d');
$b = $i[0];
require 'tmhOAuth.php';
require 'tmhUtilities.php';
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => '', // fill with consumer key
'consumer_secret' => '', // fill with consumer secret
'user_token' => '', // fill with user token
'user_secret' => '', // fill with user secret
));
$code = $tmhOAuth->request('POST', $tmhOAuth->url('1/statuses/update'), array(
'status' => "$quote[$b]"
));
if ($code == 200) {
tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
} else {
tmhUtilities::pr($tmhOAuth->response['response']);
}
$f = fopen('data.txt', 'r+' );
$count = fread($f, filesize('data.txt'));
rewind($f);
$count++;
fwrite($f, $count);
ftruncate($f, ftell($f));
fclose( $f );
Then create a file whose contents count.txt useful to be variable repetition. The contents of the file are only numbers. I use to run php cli. how to run it:
psychology @ cmyk : ~ $ php /opt/lampp/htdocs/tweetbot/tweet.php
Note : psychology is the name of your username website
Then to the transfers could use crontab, my example will run every hour, on the cronjob on your CPanel :
* 1 * * * php /opt/lampp/htdocs/tweetbot/tweet.php
Perhaps more friends can develop it further in order to become more attractive as possible by using mysql to tweet or other contents.
Download FULL SOURCE HERE