Collecting Keyword Filtered Twitter Followers with PHP
If you have read my earlier posts dealing with the subject How to use Python to get followers on Twitter I presented the programmical way to get initial burst of friends and followers. Twitter has different kind of API rate limits and one of those limits daily friend creation count to 1000. However, if you finally reach 2000 followers, the amount of people you can follow is 10% of followers, not 1000 anymore. So it means you can follow up to 2200 people in this case. And when you reach 2200 you can follow about 2420 and so on. Using this tactic means your daily increase of followers will slow down until you get up to 10000 followers. There are different kind of Twitter marketing systems, which makes it possible to overcome this limitation, but it is another subject.
Quality or quantity?
One might see this kind of follower collecting spammy behaviour or at least one way to shine personal status, but I have found two aspects to defend it. First of all search engines likes more of those accounts, that has more updates and more followers. From internet marketing view of point, that is extremely important. Choosing right Twitter account name and getting followers raises individual page rank high on SEO. Twitter pages seems to rank very well overall and status messages are crawled by search engines on high frequency. You can for example get your brand new site indexed in a matter of few hours just by creating Twitter account and tweeting content with links to your site. Another defence for agressive following is, that it doesnt really hurt communication with people. You can still keep on count and be on contact with quality people, who are actively contact with you. Nothing prevents that. Just use @reply and direct messages, or change emails, msn or other messaging protocols and learn to use Twitter search feature. It is suggested, that Twitter search will become as powerful and important as Google itself.
Twitter search
After getting initial followers I have combined both free service plus some php scripts to continue building follower base, now with more targeted users. This can be useful both for personal and business use. Using Twitter search method is great way to find real time information on what is happening in Twitterland which usually means, you know something trendy that is happening on Internet globally. You can see for example what people are reading at the moment.
Now you can get list of tweets and tweeters who are reading and what they are reading. Not exclusive list, but very good anyway. Every people that has tweet containing keyword “reading” or twitter channel tag “#reading” has some sort of interest to reading. Marketer, who owns a bookstore could use that information to follow all such tweeters. Its much better choice than random following people whose interests you dont know at all. With optional search paratemers you can make boolean searches and get even better results.
Manual and easy way now is to follow people, that get listed after search, but it will take huge amount of time especially if you have thoussands of followers in your target. I have used free service from tweetlater.com to create keyword based digest of tweets, which can be emailed once in 4, 12 or 24 hours to you. Then on the other side I have created a php script which takes forwarded email, parses its content and follows all twitter users mentioned on the digest.
Step by step
Next I will show all necesary steps to get keyword based tweet digest and give my php scripts to parse email and follow twitter users.
1. Create a new email address to your host. It is better to create a new one, because it will be forwarded to php script later and most likely cannot be used like traditional email after that. I personally have a lot of Twitter accounts, which I use for marketing so I’m using email address like: mytwittername@mydomain.com.
2. Register TweetLater.com account. When registering a new account, remember to give it same email address you just created on step 1. Tweetlater will send you confirmation email, where is a link, that you need to click to activate Tweetlater account.
3. After activation login to Tweetlater account, select Other Tools -> Keyword Alert Emails. Read instructions and give the keywords. Remember to check “Email me a keyword alert digest” and select every four hours at this point. Later you can go and change it to every 12 or every 24 hours. It depends on your keywords, but if you chooce anything as general as books, you will get hundreds of tweeters every 6 hours and it is probable, that you cannot follow them all because of rate limits told earlier.
After saving keywords Tweetlater start immediatelly collecting tweets and will send you then as an email. At this point you can wait for the first email coming to see it really works, but then you need to do following:
4. Forward the email to the php script. This can be tricky at first, but is a common feature on mail servers. You can do it on cpanel, but I have edited /etc/aliases file on my Debian Linux server and added line:
mytwittername: "|/usr/bin/php /path/to/twitter-forward.php"where mytwittername is the unix user associated with mytwittername@mydomain.com email address. Then there is a pipe |/usr/bin/php which means forward procedure to the php script twitter-forward.php on some directory path /path/to/.
5. Now you should just have next few php scripts all installed on same directory used on step 4.
a) Tweetlater and Twitter email forward script
b) Twitter helper functions
c) Twitter account classes
d) Incoming email parser class
If you use similar email address name convention as I use, there only one change you need to make on twitter-forward.php file. You need to edit username and password of your Twitter account to the right place on file which is located on array called $aAccounts:
$aAccounts = array ( // Change both Twitter name and password to real one. 'mytwittername' => 'password', // Add more accounts here. #'mytwittername2' => 'password', );
You can see, that it is possible to control several Twitter accounts and Tweetlater keywords digests with this same script.
That is it! You have created automatic keyword digest and next time the digest is emailed to you, email is forwarded to the php script. The script is configured so that forwarded email content is parsed from Twitter users which start with @mark. Then script makes you to follow all users from the digest. This is quite raw method, but because it now works on your own server, you can modify the php script and create more intelligent logic for selecting followed users like limiting maximum amount of followed users.
Important!
Once you have followed new people, you should wait one day and then purge those people who has not followed you. This is the way to add new followers and slowly (or quickly, depends how you take it) increase the follower base. Its quite easy to do it with PHP or Python and automate procedure with crontab, but there are also free services available like Your Twitter Karma which helps to do same job. I just prefer own scripts, if they do not consume too much server resources.
For additional experiment IncomingEmailParser class has methods for parsing direct messages and follow notices sent by Twitter [see: setup_twitter_info()]. This means that email address you have set to your Twitter profile can be forwarded to this script and parsed with this class. This way you can for example send your own automatic direct messages to all new followers plus some special procedures for retrieving direct messages. It can open up new exciting possibilities to use Twitter.
- Twitter bomb suspended accounts
- Twitter principles and beyond
- The viral world of Twitter
- Getting hands dirty with Python and Twitter
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

