<?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>maSnun&#039;s logs &#187; twitter</title>
	<atom:link href="http://masnun.com/blog/tag/twitter/feed/" rel="self" type="application/rss+xml" />
	<link>http://masnun.com/blog</link>
	<description>Personal Blog of maSnun</description>
	<lastBuildDate>Sat, 24 Jul 2010 04:33:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Setting Up Twitter Bots with OAuth</title>
		<link>http://masnun.com/blog/2010/04/30/setting-up-twitter-bots-with-oauth/</link>
		<comments>http://masnun.com/blog/2010/04/30/setting-up-twitter-bots-with-oauth/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 02:43:56 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://masnun.com/blog/?p=889</guid>
		<description><![CDATA[Twitter has decided to kill Basic Authentication on the Twitter API from June 30. They have setup a nice website at http://www.countdowntooauth.com/ to let you all know and help you migrate your apps to use the OAuth OAuth is cool. &#8230; <a href="http://masnun.com/blog/2010/04/30/setting-up-twitter-bots-with-oauth/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Twitter has decided to kill Basic Authentication on the Twitter API from June 30. They have setup a nice website at <a href="http://www.countdowntooauth.com/">http://www.countdowntooauth.com/</a> to let you all know and help you migrate your apps to use the OAuth <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>OAuth is cool. It&#8217;s safe and secure for the end user. It&#8217;s convenient for the developers as well. Basic Auth entirely depends on the username and password of the user. So, the developer can do whatever s/he wishes with the user account as long as the user doesn&#8217;t change the password. On the other hand, if the user for some reason changes his/her password, the application will no longer be able to access the account and provide the desired service. OAuth helps both parties here! When the user authenticates an app via OAuth, it provides the developer with an access token ( a key and a secret ) which is by no way related to the user&#8217;s password. It&#8217;s unique for every user and application pair. That is every user will have an unique access token only for that application. Now even if the user changes the password, the access token will remain unchanged. The developer can safely store the token and use that to access the user&#8217;s account without hassle. Similarly, if the user wants to revoke the access permitted to an application, he or she can easily do that. In that case, the access token becomes invalid and the application loses access to that account.</p>
<p>In the Basic Auth age, it was very easy to develop twitter bots. You just setup the username and password into a configuration file, call the REST API with the login details and you&#8217;re done! Yeah, it was quite easy. But it&#8217;s not harder now <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Don&#8217;t fret, OAuth is also very simple and easy to implement for twitter bots. While you need to go through a two phase OAuth dance to authorize other users, Twitter displays the access token of the developer directly into the dashboard! Thanks to Twitter for making things so plain for developers! With your own access token, you can authorize your apps directly without any further verification.</p>
<p>To get the access token, first go to : <a href="http://dev.twitter.com">http://dev.twitter.com</a>. Login if you&#8217;re not already logged in. Use the twitter ID you want to run as a bot. Go to <a href="http://dev.twitter.com/apps">http://dev.twitter.com/apps</a> by clicking the &#8220;Your Apps&#8221; on top right corner. You will see a list of applications under the logged in twitter account. One big advantage of the basic auth was that you didn&#8217;t need to create applications. But now you need! Create an application if you don&#8217;t already have one created. In most cases you won&#8217;t have one since this is probably the first time you&#8217;re using OAuth. In that situation, please create an application. Note down the Consumer Key and Consumer Secret after visiting the application page by clicking on any of the application name. Now, on the right hand navigation bar, you&#8217;ll see &#8220;My Access Token&#8221;. Please visit that section and retrieve your Access Token and Access Token Secret. That&#8217;s all we needed. Now let&#8217;s do some coding to demonstrate the use of these keys and secrets.</p>
<p>We first need to get a Twitter Client library. If you&#8217;re already using one, just check to make sure that it has OAuth support. The work flow is simple. First construct the client with the consumer key and consumer secret. Then set the access token key and the access token secret. Now use the client to make Twitter API calls, in our case, to update statuses! </p>
<p>You can get the OAuth libraries from : <a href="http://dev.twitter.com/pages/oauth_libraries">http://dev.twitter.com/pages/oauth_libraries</a> . But I recommend using <a href="http://github.com/joshthecoder/tweepy">Tweepy</a> with Python and <a href="http://github.com/abraham/twitteroauth">Abraham&#8217;s TwitterOAuth</a> with PHP . They are not generic OAuth clients. They were built for Twitter and you don&#8217;t need to configure any extra parameters to make it work with Twitter. </p>
<p>Here&#8217;s the code samples on how to use the libraries to update status via OAuth.</p>
<p><strong>PHP</strong> (Abraham&#8217;s TwitterOAuth)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$consumer_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$consumer_secret</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$access_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$access_secret</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitteroauth/twitteroauth.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$connection</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TwitterOAuth <span style="color: #009900;">&#40;</span><span style="color: #000088;">$consumer_key</span> <span style="color: #339933;">,</span><span style="color: #000088;">$consumer_secret</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$access_key</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$access_secret</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'statuses/update'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Hello Twitter OAuth!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Python</strong> (Tweepy)</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">consumer_key = <span style="color: #483d8b;">&quot;&quot;</span>
consumer_secret = <span style="color: #483d8b;">&quot;&quot;</span>
access_token = <span style="color: #483d8b;">&quot;&quot;</span>
access_token_secret = <span style="color: #483d8b;">&quot;&quot;</span>
&nbsp;
auth = tweepy.<span style="color: black;">OAuthHandler</span><span style="color: black;">&#40;</span>consumer_key, consumer_secret<span style="color: black;">&#41;</span>
auth.<span style="color: black;">set_access_token</span><span style="color: black;">&#40;</span>access_token, access_token_secret<span style="color: black;">&#41;</span>
bot = tweepy.<span style="color: black;">API</span><span style="color: black;">&#40;</span>auth<span style="color: black;">&#41;</span>
&nbsp;
bot.<span style="color: black;">update_status</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Hello Twitter OAuth!&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2010/04/30/setting-up-twitter-bots-with-oauth/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hosting your Twitter Bots on Google App Engine</title>
		<link>http://masnun.com/blog/2010/02/02/hosting-your-twitter-bots-on-google-app-engine/</link>
		<comments>http://masnun.com/blog/2010/02/02/hosting-your-twitter-bots-on-google-app-engine/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 11:45:56 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://masnun.com/?p=829</guid>
		<description><![CDATA[UPDATE: Download the improved version of the application. I have made some code changes after the blog post got posted to reddit. The source code is now more readable and the app easily configurable. I am amazed to see the &#8230; <a href="http://masnun.com/blog/2010/02/02/hosting-your-twitter-bots-on-google-app-engine/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: </strong> <a href="http://masnun.googlecode.com/files/twitter_bot_gae_v2.zip">Download</a>  the improved version of the application. I have made some code changes after the blog post got posted to reddit. The source code is now more readable and the app  easily configurable.</p>
<hr />
<p>I am amazed to see the implementation of cron jobs on Google App Engine. I was hosting my twitter bots on my paid shared hosting. My scripts were written in php and they were run via cron jobs set from my cPanel. Of course the cPanel cron UI is now quite familiar to me, to us who use it very often. But as a matter of fact, I can&#8217;t run per minute cron on my host. I should have a minimum interval of 15 minutes between two execution of the same cron job. I was amazed when I first discovered that Google App Engine lets me run cron every minute. Since they calculate my usage in different types of quotas, they hardly care about how often you schedule your cron. So, I decided to port my twitter bots to GAE and Python.</p>
<p>The idea was pretty simple. I already had a Yahoo! Pipe setup which mashes up multiple RSS feeds into one. My app will be collecting data from the pipe in JSON format. Then it&#8217;ll check the last tweeted entry and tweet the newer entries. Pretty straightforward algorithm. I registered a new application for my bots and started developing it on my local machine.</p>
<p>I integrated the u.nu url shortening service with their API quite easily. Though Python 2.6.2 has a built in module for JSON handling, Python 2.5 doesn&#8217;t have it. So, I had to install simplejson for JSON decoding. Later, I moved on to finding a good twitter client for my app. I first tried python-twitter. I have previously used it and it worked fine. But the application was generating some error messages when I integrated into GAE. I was puzzled and tried to find if there was something wrong in my coding. After about an hour, I concluded that my code was okay! There&#8217;s something wrong with the client. A bit of googling revealed that &#8220;python-twitter&#8221; doesn&#8217;t work on GAE without any hacks :&#8217;(. I had to find an alternative and I chose tweepy for that. It was working fine with the app.</p>
<p>Finally after 3 hours, the app was ready and it&#8217;s working! GAE doesn&#8217;t permit long execution period for a process, so I had to decrease the amount of tweets per request. But I covered that up by setting a more frequent cron job <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . I would try the new taskqueue API soon to see if that has any help for my app.</p>
<p>My twitter bots have proved handy in the past and it feels great that I can host them on a scalable and efficient platform like Google App Engine &#8212; without paying a single dollar per month! <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><strong>Download Source :</strong> <a href="http://masnun.googlecode.com/files/Twitter_BOT_GAE.zip">http://masnun.googlecode.com/files/Twitter_BOT_GAE.zip</a> <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2010/02/02/hosting-your-twitter-bots-on-google-app-engine/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Track Your Favorite Topic on Twitter: A PHP CLI Tool</title>
		<link>http://masnun.com/blog/2010/01/03/track-your-favorite-topic-on-twitter-a-php-cli-tool/</link>
		<comments>http://masnun.com/blog/2010/01/03/track-your-favorite-topic-on-twitter-a-php-cli-tool/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 16:49:42 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://masnun.com/?p=794</guid>
		<description><![CDATA[Here&#8217;s a little php utility that will let you watch the Twitter public time line for your favorite topic. This is specially helpful for those who want to build some tracking application on the basis of the twitter streaming APIs. &#8230; <a href="http://masnun.com/blog/2010/01/03/track-your-favorite-topic-on-twitter-a-php-cli-tool/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little php utility that will let you watch the Twitter public time line for your favorite topic. This is specially helpful for those who want to build some tracking application on the basis of the twitter streaming APIs.</p>
<p>Here&#8217;s the source:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$topic</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$topic</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$topic</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;php&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;twitter_username&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;twitter_password&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">{$username}</span>:<span style="color: #006699; font-weight: bold;">{$password}</span>@stream.twitter.com/1/statuses/filter.json?track=<span style="color: #006699; font-weight: bold;">{$topic}</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;r&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fgets</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$tweet</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tweet</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'text'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$tweet</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'screen_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$tweet</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'text'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; <span style="color: #000099; font-weight: bold;">\n</span> -------------------- <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Run this script with the keyword as the argument:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">php twitter.php keyword</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2010/01/03/track-your-favorite-topic-on-twitter-a-php-cli-tool/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Twitter Streaming API with Python</title>
		<link>http://masnun.com/blog/2010/01/03/twitter-streaming-api-with-python/</link>
		<comments>http://masnun.com/blog/2010/01/03/twitter-streaming-api-with-python/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 16:02:19 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://masnun.com/?p=788</guid>
		<description><![CDATA[Hasin Vai has a good post about collecting tweets in real time with php. Here&#8217;s the post: http://hasin.wordpress.com/2009/06/20/collecting-data-from-streaming-api-in-twitter/ If you are a php developer look into there. Well, I am going to cover Python for the Twitter streaming API. You &#8230; <a href="http://masnun.com/blog/2010/01/03/twitter-streaming-api-with-python/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hasin Vai has a good post about collecting tweets in real time with php. Here&#8217;s the post: <a href="http://hasin.wordpress.com/2009/06/20/collecting-data-from-streaming-api-in-twitter/">http://hasin.wordpress.com/2009/06/20/collecting-data-from-streaming-api-in-twitter/</a> <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  If you are a php developer look into there.</p>
<p>Well, I am going to cover Python for the Twitter streaming API. You need the &#8220;tweetstream&#8221; python module which depends on the &#8220;anyjson&#8221; module. Please make sure you have these modules installed before you proceed.</p>
<p>Download Links: <a href="http://pypi.python.org/pypi/anyjson">anyjson</a> |  <a href="http://pypi.python.org/pypi/tweetstream/">tweetstream</a></p>
<p>To install these packages, use the built in setup.py of the individual packages :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>In my case, I didn&#8217;t have the &#8220;setuptools&#8221; python module installed with my default python installation. So I had to install it to get the setup.py work:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> python-setuptools</pre></div></div>

<p>I love the magic of debian packages <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now, you can install the modules and dive into our example:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
<span style="color: #808080; font-style: italic;">#! /usr/bin/env python</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> tweetstream
&nbsp;
stream = tweetstream.<span style="color: black;">TweetStream</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;twitter_username&quot;</span>, <span style="color: #483d8b;">&quot;twitter_password&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> tweet <span style="color: #ff7700;font-weight:bold;">in</span> stream:
    <span style="color: #ff7700;font-weight:bold;">if</span> tweet.<span style="color: black;">has_key</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;text&quot;</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> tweet<span style="color: black;">&#91;</span><span style="color: #483d8b;">'user'</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'screen_name'</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">&quot;: &quot;</span> + tweet<span style="color: black;">&#91;</span><span style="color: #483d8b;">'text'</span><span style="color: black;">&#93;</span> , <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;-----&quot;</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">4</span></pre></div></div>

<p>That&#8217;s it! In real, you get the stream dictionary which you can use to manipulate the tweets.</p>
<p>The &#8220;tweetstream&#8221; module also lets you access the Track and Follow APIs in a superb fashion!</p>
<p>I love Twitter, I love Python! <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2010/01/03/twitter-streaming-api-with-python/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Decoding Google&#039;s Tweet With PHP</title>
		<link>http://masnun.com/blog/2009/09/05/decoding-googles-tweet-with-php/</link>
		<comments>http://masnun.com/blog/2009/09/05/decoding-googles-tweet-with-php/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 06:30:57 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[humour]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://masnun.com/?p=549</guid>
		<description><![CDATA[This is something for fun &#8212; nothing serious. It just happened that Google just sent a mysterious Tweet around 2 hours ago from now with an image with of the Google home page featuring an UFO. The UFO was seen &#8230; <a href="http://masnun.com/blog/2009/09/05/decoding-googles-tweet-with-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is something for fun &#8212; nothing serious. It just happened that Google just sent a <a href="http://twitter.com/google/status/3772868874">mysterious Tweet </a> around 2 hours ago from now with an image with of the Google home page featuring an UFO. The UFO was seen pulling an O out of the google logo. But what the heck does that tweet mean ?</p>
<p><strong>1.12.12 25.15.21.18 15 1.18.5 2.5.12.15.14.7 20.15 21.19 </strong> was the tweet.</p>
<p>Well, it&#8217;s nothing tough. Every number separated by a dot or space corresponds to the alphabet. So, I wrote a PHP script to decode this mysterious tweet and finally found the meaning:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
masnun<span style="color: #000000; font-weight: bold;">@</span>ubuntu:~<span style="color: #000000; font-weight: bold;">/</span>Desktop$ php decode-google-tweet
all your o are belong to us
masnun<span style="color: #000000; font-weight: bold;">@</span>ubuntu:~<span style="color: #000000; font-weight: bold;">/</span>Desktop$</pre></div></div>

<p>So, it meant <b>&#8221; all your o are belong to us &#8221; </b> <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
Sounds a bit odd ? Or wrong in grammar ? yeah, still, that&#8217;s the message. It is confirmed on the twitpic image.</p>
<p>And here&#8217;s the source code &#8211;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$num</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// placeholder for 1 to 26</span>
<span style="color: #000088;">$alpha</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// placeholder for a to z</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">27</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$num</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// dynamically store 1 to 26 in the array</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'a'</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #0000ff;">'z'</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$alpha</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// dynamically store a to y in the array</span>
<span style="color: #000088;">$alpha</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'z'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// manually add z to the array</span>
<span style="color: #000088;">$dict</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_combine</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #339933;">,</span><span style="color: #000088;">$alpha</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// combine them to form a dictionary</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// print_r($dict);</span>
&nbsp;
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;1.12.12 25.15.21.18 15 1.18.5 2.5.12.15.14.7 20.15 21.19&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// the code to decode</span>
<span style="color: #000088;">$arr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// differentiate the parts</span>
&nbsp;
<span style="color: #000088;">$meaning</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// placeholder for the ultimate meaning</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span>count<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// dot seperated portions</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// seperate the numbers</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span><span style="color: #339933;">&lt;</span>count<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// get individual numbers</span>
<span style="color: #000088;">$meaning</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$dict</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// look up in the dictionary for the corresponding char</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$meaning</span> <span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// restore the spaces</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$meaning</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// echo the meaning</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>It was quite a bit of fun decoding the message with PHP. Well, I do agree that there was no need to use PHP here. But why do the hard work from memory when you have automation tools at your hand <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ?</p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/09/05/decoding-googles-tweet-with-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fun with Twitter OAuth: The Source Code</title>
		<link>http://masnun.com/blog/2009/08/30/fun-with-twitter-oauth-the-source-code/</link>
		<comments>http://masnun.com/blog/2009/08/30/fun-with-twitter-oauth-the-source-code/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 07:08:21 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://masnun.com/?p=480</guid>
		<description><![CDATA[In my previous post, I mentioned about the twitter OAuth app hosted at: http://masnun.com/twitter-app/ . Here it comes, the source code. I am not going to include the Twitter OAuth Library source. You have to download it from Github. The &#8230; <a href="http://masnun.com/blog/2009/08/30/fun-with-twitter-oauth-the-source-code/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In my previous post, I mentioned about the twitter OAuth app hosted at: <a href="http://masnun.com/twitter-app/">http://masnun.com/twitter-app/</a> . Here it comes, the source code.</p>
<p>I am not going to include the Twitter OAuth Library source. You have to download it from Github. The link is available in my previous post.</p>
<p><strong>consumer.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Filename: consumer.php</span>
<span style="color: #666666; font-style: italic;">// contains the consumer key and consumer secret</span>
<span style="color: #666666; font-style: italic;">// works as a configuration file that can be included in other</span>
<span style="color: #666666; font-style: italic;">// scripts.</span>
<span style="color: #000088;">$consumer_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Ll0Sq8HyJzBOqXqksH7N4w'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$consumer_secret</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'WwMdrN13UTJL79KyI6unm3xTm5tdF8E4U3FMKE7i5co'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>index.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Filename: index.php</span>
<span style="color: #666666; font-style: italic;">// The file that gets called when you visit the app home page</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// require twitterOAuth lib</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitterOAuth.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// require the consumer details -- consumer key and consumer secret</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'consumer.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//construct a new twitter object</span>
<span style="color: #000088;">$twitter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TwitterOAuth<span style="color: #009900;">&#40;</span><span style="color: #000088;">$consumer_key</span><span style="color: #339933;">,</span><span style="color: #000088;">$consumer_secret</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// get the token to make an authorization request</span>
<span style="color: #000088;">$token</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequestToken</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// store the token for further use</span>
<span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;token&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;token_secret&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token_secret'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// build the authorization url</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAuthorizeURL</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// redirect the user to the authorization url automatically</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: <span style="color: #006699; font-weight: bold;">$url</span> &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>return.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//Filename: return.php</span>
<span style="color: #666666; font-style: italic;">// It's the callback file -- gets called</span>
<span style="color: #666666; font-style: italic;">// the user is returned to this file on authorization</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// include twitter OAuth library as usual</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitterOAuth.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// include the consumer details</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'consumer.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// retrieve the tokens</span>
<span style="color: #000088;">$tok</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;token&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tok_sec</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;token_secret&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// construct the twitter object</span>
<span style="color: #000088;">$twitter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TwitterOAuth<span style="color: #009900;">&#40;</span><span style="color: #000088;">$consumer_key</span><span style="color: #339933;">,</span><span style="color: #000088;">$consumer_secret</span><span style="color: #339933;">,</span><span style="color: #000088;">$tok</span><span style="color: #339933;">,</span><span style="color: #000088;">$tok_sec</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// retrieve the access token set by the authorization</span>
<span style="color: #000088;">$access_token</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAccessToken</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// parse the tokens and seperate them</span>
<span style="color: #000088;">$tok</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$access_token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tok_secret</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$access_token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token_secret'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// print_r($access_token);</span>
<span style="color: #666666; font-style: italic;">// construct the twitter object</span>
<span style="color: #666666; font-style: italic;">// this time with the access tokens</span>
<span style="color: #000088;">$twitter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TwitterOAuth<span style="color: #009900;">&#40;</span><span style="color: #000088;">$consumer_key</span><span style="color: #339933;">,</span><span style="color: #000088;">$consumer_secret</span><span style="color: #339933;">,</span><span style="color: #000088;">$tok</span><span style="color: #339933;">,</span><span style="color: #000088;">$tok_secret</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// make API call</span>
<span style="color: #000088;">$req</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span> <span style="color: #339933;">-&gt;</span><span style="color: #004000;">OAuthRequest</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'https://twitter.com/statuses/update.xml'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Check out: http://masnun.com/twitter-app/ :)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'POST'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// print_r($req);</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//redirect the user to twitter home page</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: http://twitter.com &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><b>Notes On OAuth:</b><br />
First we, construct the twitter object with the consumer details.<br />
Then we ask for a request token. We build the authorization url with this token.<br />
We send the user to the auth URL.<br />
When the user returns, again construct a twitter object with consumer details and the request token we retrieved previously.<br />
Now that the user is authorized, we ask for access tokens.<br />
We have the access tokens now, so build a new twitter object that has full access to the API.</p>
<p>Now, we can make API calls.</p>
<p>The steps may seem a bit odd at first look. Just go through a couple of times and you&#8217;ll get it clearly.</p>
<p>Enjoy OAuthentication, Enjoy Twitter enginnering !!</p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/08/30/fun-with-twitter-oauth-the-source-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter OAuth Fun :D</title>
		<link>http://masnun.com/blog/2009/08/29/twitter-oauth-fun-d/</link>
		<comments>http://masnun.com/blog/2009/08/29/twitter-oauth-fun-d/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 00:33:12 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[humour]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://masnun.com/?p=467</guid>
		<description><![CDATA[My University is off for about a month and I am thinking of passing this huge time in some sort of productive work. I love coding and experimenting. Twitter and PHP being my favourites, I decided to check out the &#8230; <a href="http://masnun.com/blog/2009/08/29/twitter-oauth-fun-d/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My University is off for about a month and I am thinking of passing this huge time in some sort of productive work. I love coding and experimenting. Twitter and PHP being my favourites, I decided to check out the Twitter API and cook something up with PHP. I have already used the Basic Authentication API calls in the past (to develop the twitter mobile publisher at <a href="http://masnun.com/twitter/">http://masnun.com/twitter/</a> which is my major tool to tweet while I am on the go). This time I decided to try the OAuth API mainly for two reasons &#8212; 1) I need to explore the OAuth system and 2) I have a project coming on based on the twitter OAuth API.</p>
<p>So, I started studying the Twitter OAuth API and learnt it pretty well. Then I thought what kind of application I could build with this very newly gathered knowledge ? Why not make some fun ? Yeah, I just can&#8217;t help making fun every now and then.</p>
<p>Finally, here it is &#8212; <a href="http://masnun.com/twitter-app/">http://masnun.com/twitter-app/</a> <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>It&#8217;s a little devil app that automatically takes you to the authorization URL and asks for OAuth based authentication. If you allow it, it will automatically make a tweet using your account. The tweet will be nothing bad though, just a link back to the app <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>To develop this app, I have used the official Twitter OAuth library for PHP written by Abraham. <strong>Download it: </strong>  <a href="http://github.com/abraham/twitteroauth">http://github.com/abraham/twitteroauth</a> .</p>
<p><strong>Points to Ponder:</strong></p>
<ul>
<li>An application can do almost anything to your twitter account once you approve it.</li>
<li>Twitter says, the access token they provide doesn&#8217;t expire. That means once you approve an application, it can use your account forever if they are clever enough to store your access token details.</li>
<li>While approving an application, you never know what kind of permission the application has &#8212; read only or read-write both. I think this option should be left upon the users. The users should be able to choose whether he wants to provide write access or not.</li>
</ul>
<p>I have seen some web sites exploit Twitter accounts. TweeterFollow is a decent example of such nasty practices. Once you provide your credentials, they&#8217;ll regularly tweet their links from your account. So think twice before you approve an application though OAuth is safer than providing password since you can choose to withdraw your permission to an application.</p>
<p>I will write detailed about OAuth and provide the source code in another post. Just now, I am feeling extremely sleepy. Woke up to have my Sehri and didn&#8217;t return to bed. It&#8217;s time I had a nap&#8230; <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/08/29/twitter-oauth-fun-d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter Bot Earns Me Money :)</title>
		<link>http://masnun.com/blog/2009/08/27/twitter-bot-earns-me-money/</link>
		<comments>http://masnun.com/blog/2009/08/27/twitter-bot-earns-me-money/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 18:03:13 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://masnun.com/?p=435</guid>
		<description><![CDATA[Well, this came up as a pleasant surprise to me when I logged into my GetAFreeLancer.com account to deactivate the email notification. I have earned $34.2 in August 2009 from affiliate activity. I was puzzled first and then checked out &#8230; <a href="http://masnun.com/blog/2009/08/27/twitter-bot-earns-me-money/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, this came up as a pleasant surprise to me when I logged into my GetAFreeLancer.com account to deactivate the email notification. I have earned $34.2 in August 2009 from affiliate activity. I was puzzled first and then checked out the whole thing. One of the people whom I referred to GAF, created two projects there and I got the commission.</p>
<p>I am quite active on scriptlance and was getting bored with GAF for their very frequent email notification. Finally, I decided to turn off the notifications and deactivate my account. But now that GAF is earning me money from referrals, I am quite happy with them.</p>
<p>The referral links are being spread over the microblogsphere by my twitter bot that collects direct links to available projects on GAF and tweets them. I set up the bot out of experimental purpose but now it looks like it&#8217;s gonna be a good money maker as well.</p>
<p>Being inspired by this little surprise , I made some upgrades to the bot. The bot now adds hash sign (#) before important key words to make it search friendly. I also activated a identi.ca and a friendfeed clone of the same bot.</p>
<p>I am thinking of selling this entire bot script at $30. Anyone interested? Bargaining allowed for sure <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/08/27/twitter-bot-earns-me-money/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
