In my previous post I’ve given a php script which can be used to create twitter bots. Here I’m explaining how to create twitter bot using that app. No coding skills are required to create bot using the above script. Before going through this article, please make sure that you’ve,
1. a twitter account for your bot, ![]()
2. a web server with latest version of php installed.
This app works on OAuth, so you’ve to get API key for your bot application. To get twitter API keys, go to http://dev.twitter.com and register your app. (Look at the below table for help on filling up required fields)
| Name: | Name of your twitter bot application. Eg: My bot |
| Description: | Description of your app. Anything Between 10 and 200 characters. |
| WebSite: | Your website address. You’ll get backlink on every tweet your bot tweets! |
| Application icon: | Upload icon for your app. Not mandatory. |
| Application type: | Read and Write |
| Callback URL: | Leave it blank |
| Organization name: | If any.. Or your name |
| Organization website: | If any.. Or your website |
Now save your application and get Consumer key and Consumer secret, and create Access token for your account. Then get your Access token and Access token secret.
For example:
| Consumer key | as6d5f4a96s8f4as65df |
| Consumer secret | asdf7a9847tq34523654df6g4 |
| Access token | sdf45as68f7re8gha65df4vbas8das6f8as6df87 |
| Access token secret | asdf45as8df74a89g5a6s4g-as5df4as-sad56f4a6s |
Now download twitter bot php script from here and upload it to your web server using ftp. Then edit config.php and fill up required fields. i.e CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET
Eg:
1 2 3 4 | define('CONSUMER_KEY', 'as6d5f4a96s8f4as65df'); define('CONSUMER_SECRET', 'asdf7a9847tq34523654df6g4'); define('ACCESS_TOKEN', 'sdf45as68f7re8gha65df4vbas8das6f8as6df87'); define('ACCESS_TOKEN_SECRET', 'asdf45as8df74a89g5a6s4g-as5df4as-sad56f4a6s'); |
Then replace search key word with the word of your bot’s subject. It retweets all the tweets containing that word. Eg: for a Linux bot replace search key word with Linux. rpp means the number of tweets to grab at once. For an ideal bot, this should be less than 20. Otherwise your account would be suspended.. ![]()
Example:
$search = $twitter->get('search', array('q' => 'linux', 'rpp' => 15)); |
Now save the file and try to view that file in your browser. i.e http://yourwebsite/twitterbot/config.php. If you see a blank page and your bot starts to tweet, then it indicates thumbs up
. Now set Cron Job for config.php file at the interval of 30 minutes.
/usr/bin/php -q /home/your_username/public_html/twitterbot/config.php
Thats all. Your bot should be working now! ![]()
Download twitter bot script: [download id="1"]
Follow me on twitter @prasannasp
Follow these topics Blog, Technology
Short Link:


17 comments
Skip to comment form ↓
Daniel
February 3, 2013 at 10:28 am (UTC 5.5) Link to this comment
Brilliant! Took a little tweaking, and building 2 Twitter apps, since the first one didn’t take, but otherwise working beautifully manually and via chron job. I updated the bot to search & tweet a specific phrase when finding keywords, which is also working like a charm. Thanks P!!!
Sean Smyth
February 7, 2013 at 4:42 am (UTC 5.5) Link to this comment
Hey this works but I’m interested in having it constantly searching.
A cron Job is ok but ideally this would happen in real time.
I’ve a small team of people who I’d love to run a contant search on their accounts. If any of them tweet with a certain hashtag, I’d love to be able to post their tweet on the company account automatically.
GroupTweet offer what I’m asking but they’ve limits. I’m basically wanting to build my own GroupTweet both as a coding exercise and I’m cheap and don’t want to pay for it
Is this possible using this method and this technology? or should I be looking in another direction?
Any advice would be greatly appreciated.
View all comments