<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Random Approaches &#187; php</title>
	<atom:link href="http://www.randapp.com/blog/category/programming/php-programming/feed" rel="self" type="application/rss+xml" />
	<link>http://www.randapp.com/blog</link>
	<description>Online Business Investigations and Music Research</description>
	<lastBuildDate>Thu, 08 Apr 2010 06:55:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Collecting Keyword Filtered Twitter Followers with PHP</title>
		<link>http://www.randapp.com/blog/collecting-keyword-filtered-twitter-followers-with-php</link>
		<comments>http://www.randapp.com/blog/collecting-keyword-filtered-twitter-followers-with-php#comments</comments>
		<pubDate>Wed, 22 Jul 2009 17:11:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Twitter]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[clean page]]></category>

		<guid isPermaLink="false">http://www.randapp.com/blog/?p=215</guid>
		<description><![CDATA[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 [...]

<ol><li><a href='http://www.randapp.com/blog/twitter-bomb-suspended-accounts' rel='bookmark' title='Permanent Link: Twitter bomb suspended accounts'>Twitter bomb suspended accounts</a></li>
<li><a href='http://www.randapp.com/blog/twitter-principles-and-beyond' rel='bookmark' title='Permanent Link: Twitter principles and beyond'>Twitter principles and beyond</a></li>
<li><a href='http://www.randapp.com/blog/the-viral-world-of-twitter' rel='bookmark' title='Permanent Link: The viral world of Twitter'>The viral world of Twitter</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If you have read my earlier posts dealing with the subject <a href="http://www.randapp.com/blog/getting-hands-dirty-with-python-and-twitter">How to use Python to get followers on Twitter</a> 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 <a href="http://budurl.com/TwitterMarketMachine">Twitter marketing systems</a>, which makes it possible to overcome this limitation, but it is another subject.</p>
<p><strong>Quality or quantity?</strong></p>
<p>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.</p>
<p><strong>Twitter search</strong></p>
<p>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 <a href="http://bit.ly/TqOT4">reading</a> at the moment.</p>
<p>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 &#8220;reading&#8221; or twitter channel tag &#8220;#reading&#8221; 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.</p>
<p>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 <a href="http://budurl.com/tlater">tweetlater.com</a> 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.</p>
<p><strong>Step by step</strong></p>
<p>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.</p>
<p><strong>1.</strong> 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&#8217;m using email address like: mytwittername@mydomain.com.</p>
<p><strong>2.</strong> Register <a href="http://budurl.com/tlater">TweetLater.com</a> 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.</p>
<p><strong>3.</strong> After activation login to Tweetlater account, select Other Tools -> Keyword Alert Emails. Read instructions and give the keywords. Remember to check &#8220;Email me a keyword alert digest&#8221; 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 <em>books</em>, 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.</p>
<p><a href="http://www.randapp.com/wp-local/uploads/2009/07/kuva-4.png"><img src="http://www.randapp.com/wp-local/uploads/2009/07/kuva-4-300x185.png" alt="Tweetlater keyword digest" title="Tweetlater keyword digest" width="300" height="185" class="alignnone size-medium wp-image-229" /></a></p>
<p>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:</p>
<p><strong>4.</strong> 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 <a href="http://2.bp.blogspot.com/_HoUoXf5cdPw/STowyZm8iXI/AAAAAAAAAIw/kvQTZHRRjnU/s1600-h/Forward+email+to+scripti.jpg">cpanel</a>, but I have edited /etc/aliases file on my Debian Linux server and added line:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">mytwittername: <span style="color: #7f007f;">&quot;|/usr/bin/php /path/to/twitter-forward.php&quot;</span></pre></div></div>

<p>where <em>mytwittername</em> is the unix user associated with <em>mytwittername@mydomain.com</em> email address. Then there is a pipe <em>|/usr/bin/php</em> which means forward procedure to the php script <em> twitter-forward.php</em> on some directory path <em>/path/to/</em>.</p>
<p><strong>5.</strong> Now you should just have next few php scripts all installed on same directory used on step 4.</p>
<p>a) <a href="http://www.randapp.com/wp-local/uploads/2009/07/twitter-forward.php">Tweetlater and Twitter email forward script</a><br />
b) <a href="http://www.randapp.com/wp-local/uploads/2009/07/twitter-functions.php">Twitter helper functions</a><br />
c) <a href="http://www.randapp.com/wp-local/uploads/2009/07/twitteraccount.php">Twitter account classes</a><br />
d) <a href="http://www.randapp.com/wp-local/uploads/2009/07/incomingemailparser.php">Incoming email parser class</a></p>
<p>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:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$aAccounts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>
    <span style="color: #666666; font-style: italic;">// Change both Twitter name and password to real one.</span>
    <span style="color: #0000ff;">'mytwittername'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span>
    <span style="color: #666666; font-style: italic;">// Add more accounts here.</span>
    <span style="color: #666666; font-style: italic;">#'mytwittername2' =&gt; 'password',
</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You can see, that it is possible to control several Twitter accounts and Tweetlater keywords digests with this same script.</p>
<p>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.</p>
<p><strong>Important!</strong></p>
<p>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 <a href="http://www.dossy.org/twitter/karma">Your Twitter Karma</a> which helps to do same job. I just prefer own scripts, if they do not consume too much server resources.</p>
<p>For additional experiment <a href="http://www.randapp.com/wp-local/uploads/2009/07/incomingemailparser.php">IncomingEmailParser</a> 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.</p>
<script type="text/javascript" class="owbutton" src="http://onlywire.com/btn/button_3793" title="Collecting Keyword Filtered Twitter Followers with PHP" url="http://www.randapp.com/blog/collecting-keyword-filtered-twitter-followers-with-php"></script>

<ol><li><a href='http://www.randapp.com/blog/twitter-bomb-suspended-accounts' rel='bookmark' title='Permanent Link: Twitter bomb suspended accounts'>Twitter bomb suspended accounts</a></li>
<li><a href='http://www.randapp.com/blog/twitter-principles-and-beyond' rel='bookmark' title='Permanent Link: Twitter principles and beyond'>Twitter principles and beyond</a></li>
<li><a href='http://www.randapp.com/blog/the-viral-world-of-twitter' rel='bookmark' title='Permanent Link: The viral world of Twitter'>The viral world of Twitter</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.randapp.com/blog/collecting-keyword-filtered-twitter-followers-with-php/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
