<?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>Our Geek Space &#187; python</title>
	<atom:link href="http://blog.moove-it.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.moove-it.com</link>
	<description>be free to express yourself...</description>
	<lastBuildDate>Thu, 26 Jan 2012 19:30:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>blahsports &amp; marketing campaign of Maradona</title>
		<link>http://blog.moove-it.com/blahsports-marketing-campaign-of-maradona/</link>
		<comments>http://blog.moove-it.com/blahsports-marketing-campaign-of-maradona/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 20:07:27 +0000</pubDate>
		<dc:creator>Martin Cabrera</dc:creator>
				<category><![CDATA[moove-it]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[soccer]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[blahsports]]></category>
		<category><![CDATA[crowller]]></category>
		<category><![CDATA[maradona]]></category>
		<category><![CDATA[marketing]]></category>
		<category><![CDATA[marketing campaign]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.moove-it.com/?p=322</guid>
		<description><![CDATA[Currently we are the developing team of blahsports. Since January 2010 we have been developing several new functionalities and administrating the whole Site. Blahsports &#8211; www.blahsports.com Blahsports is a social content website. As a user, you participate in determining all site&#8217;s content by providing, selecting, sharing, and discussing articles, pictures and videos that you like [...]]]></description>
			<content:encoded><![CDATA[<p>Currently we are the developing team of blahsports. Since January 2010 we have been developing several new functionalities and administrating the whole Site.</p>
<p><strong>Blahsports</strong> &#8211; <a title="blahsports" href="http://www.blahsports.com" target="_blank">www.blahsports.com</a></p>
<p>Blahsports is a social content website. As a user, you participate in  determining all site&#8217;s content by providing, selecting, sharing, and  discussing articles, pictures and videos that you like and feel that  would be interesting to other people.</p>
<p>see the site &#8230;</p>
<table border="0">
<tbody>
<tr>
<td><a title="Blahsports site" href="http://www.blahsports.com" target="_blank"><img class="alignleft size-full wp-image-330" title="blahsports_site" src="http://blog.moove-it.com/wp-content/uploads/2010/06/blahsports_site.png" alt="blahsports_site" width="657" height="449" /></a></td>
</tr>
</tbody>
</table>
<p><span style="text-decoration: underline;"><em>Blah and technology</em></span></p>
<p>This project is based on PHP, codeigniter (<a title="CodeIgniter" href="http://codeigniter.com/" target="_blank">www.codeigniter.com</a>), Python and MYSQL.<br />
It uses RSS and Web crowller application developed in Python to share all the sports content of a hundred sites.<br />
We create a tag module which searches and identifies the language, sports and a set of tags for each content. For instance, if the content is &#8220;Forlan plays very well against Mexico&#8221; then the module will find out that the text is about Soccer, Forlan, Mexico and that the main language is English.</p>
<p><em><span style="text-decoration: underline;">blah and a marketing campaign</span><br />
</em></p>
<p>We are making a marketing campaign to <span id="result_box"><span>acquire and activate users.  We have a Maradona t-shirt as a prize for the winner among </span></span><span id="result_box"><span style="background-color: #e6ecf9; color: #000000;"> </span></span>all the registered users &#8230; see the site &#8230; <a href="http://maradona.blahsports.com" target="_blank">http://maradona.blahsports.com</a></p>
<p><span id="result_box"><span>This application was developed based on rails.</span></span></p>
<p><a title="maradona marketing campaign" href="http://maradona.blahsports.com" target="_blank"><img class="alignleft size-full wp-image-323" title="promo_maradona" src="http://blog.moove-it.com/wp-content/uploads/2010/06/promo_maradona.png" alt="promo_maradona" width="641" height="420" /></a></p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://blog.moove-it.com/blahsports-marketing-campaign-of-maradona/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interfacing with Twitter</title>
		<link>http://blog.moove-it.com/interfacing-with-twitter/</link>
		<comments>http://blog.moove-it.com/interfacing-with-twitter/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 15:30:42 +0000</pubDate>
		<dc:creator>Gian Zas</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[interfacing twitter]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[restful]]></category>
		<category><![CDATA[twitter python rest]]></category>

		<guid isPermaLink="false">http://blog.moove-it.com/?p=116</guid>
		<description><![CDATA[Tweet tweet tweet! All the farm is chating about Twitter, all the farm is using twitter and all the farm is building applications on top of it. Luckily, Twitter seems to be a programmer&#8217;s best friend, why? you may be asking&#8230; because of its wonderful API. Well designed and documented, what else could you wish? [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-117" title="twitter_bird" src="http://blog.moove-it.com/wp-content/uploads/2009/03/twitter_post.jpg" mce_src="http://blog.moove-it.com/wp-content/uploads/2009/03/twitter_post.jpg" alt="twitter_bird" height="95" width="161">Tweet tweet tweet! All the farm is chating about <b>Twitter</b>, all the farm is using twitter and all the farm is building applications on top of it.</p>
<p>Luckily, Twitter seems to be a programmer&#8217;s best friend, why? you may be asking&#8230; because of its wonderful <b>API</b>. Well designed and documented, what else could you wish?</p>
<p>The Twitter <b>API is RESTful</b>, but it doesn&#8217;t only mean that you can access to it over <b>HTTP</b>, sending parameters in <b>GET </b>or <b>POST </b>requests, it also means that it is designed complying with the <a href="http://blog.moove-it.com/?p=74" mce_href="http://blog.moove-it.com/?p=74">principles of REST</a>. A plus to this API is that it supports <b>JSON</b>, <b>XML</b>, <b>RSS</b> and <b>Atom </b>data formats and user authentication is reached by<b> Basic Auth</b>.</p>
<p>Due to the popularity of the service, a bunch of libraries have been developed and are heavily used to interact with Twitter, but if you like to explore the other end of the telephone line you are reading the right post <img src='http://blog.moove-it.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . As we&#8217;ve said the API is accessible through HTTP, so let&#8217;s go and fire up your browser and point to:</p>
<p><b><span style="color: rgb(51, 102, 255);" mce_style="color: #3366ff;">http://twitter.com/statuses/user_timeline.xml?screen_name=twitterapi</span></b></p>
<p>Ok, what do you see? the last tweets of the user whose screen name is <b>twitterapi </b>formatted in xml. Another popular operation is:</p>
<p><b><span style="color: rgb(51, 102, 255);" mce_style="color: #3366ff;">http://twitter.com/statuses/friends_timeline.json?</span></b></p>
<p>That url returns (after successful authentication) the latest tweets posted by the authenticated user and it&#8217;s friends.</p>
<p>Because requesting a <b>URL </b>and satisfying basic authentication mechanisms are easy tasks in the day-to-day programming languages, invoking the API is a piece of cake. As <b>Python </b>has been one of our favorite languages, we&#8217;ll show you how to retrieve user statuses and post a new one. Here we go!</p>
<pre><b><span style="color: rgb(51, 153, 102);" mce_style="color: #339966;">import simplejson as jsonimport urllibimport urllib2</span></b></pre>
<pre><span style="color: rgb(51, 153, 102);" mce_style="color: #339966;"><b>GET_STATUS_URL = 'http://twitter.com/statuses/user_timeline.json?'UPDATE_STATUS_URL = 'http://twitter.com/statuses/update.json?'</b></span></pre>
<p>First we must declare the necessary imports (simplejson must be downloaded and installed before) and declare the URLs to be accessed.</p>
<pre><b><span style="color: rgb(51, 153, 102);" mce_style="color: #339966;">def get_statuses(screen_name):&nbsp;&nbsp;&nbsp; data = {'screen_name' : screen_name}</span><span style="color: rgb(51, 153, 102);" mce_style="color: #339966;">&nbsp; &nbsp; url = GET_STATUS_URL + urllib.urlencode(data)</span><span style="color: rgb(51, 153, 102);" mce_style="color: #339966;">&nbsp;&nbsp;&nbsp; f = urllib2.urlopen(url)</span><span style="color: rgb(51, 153, 102);" mce_style="color: #339966;">&nbsp;&nbsp;&nbsp; response = ''.join(f.readlines())&nbsp; &nbsp; return json.loads(response)</span></b></pre>
<p><b>get_statuses</b> retrieves the last tweets of <b>#{screen_name}</b>, it simply adds the screen_name parameter to the url, then requests it and finally parse the response using the json library.  To print the tweets retrieved in a simple manner:</p>
<pre><b><span style="color: rgb(51, 153, 102);" mce_style="color: #339966;">&nbsp;&nbsp;&nbsp; statuses = get_statuses(username)&nbsp;&nbsp;&nbsp; for status in statuses:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "# " + status['user']['screen_name'] + ": " + status['text']</span></b></pre>
<pre><b></b></pre>
<p>To post a tweet we simply do a POST request to the <b>UPDATE_STATUS_URL</b> passing the status (the tweet&#8217;s text) parameter.</p>
<pre><b><span style="color: rgb(51, 153, 102);" mce_style="color: #339966;">def update_status(username, password, status):&nbsp;&nbsp;&nbsp; __authenticate(username, password)&nbsp;&nbsp;&nbsp; data = {'status' : status}&nbsp;&nbsp;&nbsp; f = urllib2.urlopen(UPDATE_STATUS_URL, urllib.urlencode(data))&nbsp;&nbsp;&nbsp; response = ''.join(f.readlines())</span></b>    <span style="color: rgb(51, 153, 102);" mce_style="color: #339966;"><b>return json.loads(response)</b></span></pre>
<p>Username and password corresponds to the twitter user (you for example) whose status will be updated, obviously the user (ex: you again) must have a twitter account.</p>
<p>Because the API uses basic authentication we call to the <b>__authenticate</b> function:</p>
<pre><b><span style="color: rgb(51, 153, 102);" mce_style="color: #339966;">def __authenticate(username, password):&nbsp; &nbsp; passman = urllib2.HTTPPasswordMgrWithDefaultRealm()&nbsp;&nbsp;&nbsp; passman.add_password(None, TWITTER_HOST, username, password)&nbsp; &nbsp; auth_handler = urllib2.HTTPBasicAuthHandler(passman)&nbsp;&nbsp;&nbsp; opener = urllib2.build_opener(auth_handler)&nbsp; &nbsp; urllib2.install_opener(opener)</span></b></pre>
<p>For a good explanation on how this chunk of code works, please refer to&nbsp; <a href="http://www.voidspace.org.uk/python/articles/authentication.shtml" mce_href="http://www.voidspace.org.uk/python/articles/authentication.shtml">this great tutorial</a><br mce_bogus="1"></p>
<p>As you&#8217;ve seen, in a small amount of code we are interacting with Twitter, where to use it, how to display the results and what ideas bring<br />
to life is up to you!</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://blog.moove-it.com/interfacing-with-twitter/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

