|Creating extended Twitter bot with PHP|
If you try to search in the Web info about creating Twitter bot then you will find a lot if articles and blog messages about this. But most of them are just examples of code that posts twitt (message) to Twitter.
This is not enough to create full function Twitter bot.
Good Twitter bot should: post twitts, subscribe for new users by given subject, somehow make another users to subscribe for needed account. Actually, last task is most important - grow count of subscribers for some account.
There is example of such bot - Extended Twitter bot with PHP.
I used twitterlibphp to work with Twitter API. It is nice PHP class by Justin Poliey.
I think most useful task of Twitter bot is to increase count of subscribers for some twitter account.
To achieve this i used my own resume after using of twitter. Usually, when some account becomes my subscriber i get notification email and i am going to look what is that account. If that is something i am interested in i subscribe for that account too.
Based on this resume, i created bot that have list of functions:
Filtering of accounts to subscribe
It is easy to search for accounts by keywords. But not all accounts are good for subscription . There are a lot of bots in the Twitter. I read somewhere that 80% of accounts are bots!
It is needed to filter bots accounts and process only "real" accounts - accounts that are used by human .
To solve this task i also used my experience in twitter. I found that real accounts have few subscriptions (<50) and bots usually have a lot of subscriptions (>100) .
So, there is simple criteria. If account have more then 50 subscriptions then this is bot and account must be ignored. This is not 100% true. But i most cases this works.
Functioning of the bot.
Another important thing for twitter bot (and any other bot) is balance in doing of API requests. It is not good to do request by request. In this case twitter can easy know that this are requests from a bot.
My bot works with scenario that is saved in settings.
Scenario looks like:
Cron task starts the bot each minute. The bot looks in DB for next step in scenario and execute task. Pause means to do nothing.
In next my articles i will describe the code of the bot.
|Last Updated on Sunday, 07 March 2010 14:28|