<?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>Mea Cup O' Jo &#187; Twitter</title>
	<atom:link href="http://dev.bostone.us/category/twitter/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.bostone.us</link>
	<description>Jump Right Ahead In My Web</description>
	<lastBuildDate>Tue, 11 May 2010 05:15:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Spritzer your Twitter</title>
		<link>http://dev.bostone.us/2009/07/31/spritzer-your-twitter/</link>
		<comments>http://dev.bostone.us/2009/07/31/spritzer-your-twitter/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 18:58:02 +0000</pubDate>
		<dc:creator>bo</dc:creator>
				<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://dev.bostone.us/?p=218</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>I know, I know &#8211; it&#8217;s probably old news but I just discover <a href="http://apiwiki.twitter.com/Streaming-API-Documentation">Twitter&#8217;s streaming API</a>. For these of you who is not in the know or how: anyone with valid Twitter account can monitor Twitter public postings in realtime. It may not get regular users excited but for developers &#8211; imaging you are eavesdropping on the whole world! You can get it in compact JSON format or more elaborate XML but generally it will look as long sequence of the following single snippet</p>
<pre name="code" class="xml">
<?xml version="1.0" encoding="UTF-8"?>
<status>
  <created_at>Thu Jul 30 16:28:23 +0000 2009</created_at>
  <id>2932899702</id>
  <text>@shonda305 @msmayad sore throat</text>
  <source>&lt;a href="http://www.twhirl.org/"&gt;twhirl&lt;/a&gt;</source>
<truncated>false</truncated>
  <in_reply_to_status_id></in_reply_to_status_id>
  <in_reply_to_user_id>38761568</in_reply_to_user_id>
  <favorited>false</favorited>
  <in_reply_to_screen_name>shonda305</in_reply_to_screen_name>
  <user>
    <id>18806564</id>
    <name>jazzyattitude</name>
    <screen_name>jazzyattitude</screen_name>
    <location>Florida </location>
    <description>one of a kind</description>
<profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/333149534/DSC00347_normal.JPG</profile_image_url>
    <url></url>
<protected>false</protected>
    <followers_count>85</followers_count>
<profile_background_color>709397</profile_background_color>
<profile_text_color>333333</profile_text_color>
<profile_link_color>FF3300</profile_link_color>
<profile_sidebar_fill_color>A0C5C7</profile_sidebar_fill_color>
<profile_sidebar_border_color>86A4A6</profile_sidebar_border_color>
    <friends_count>43</friends_count>
    <created_at>Fri Jan 09 16:54:26 +0000 2009</created_at>
    <favourites_count>0</favourites_count>
    <utc_offset>-18000</utc_offset>
    <time_zone>Eastern Time (US &amp; Canada)</time_zone>
<profile_background_image_url>http://static.twitter.com/images/themes/theme6/bg.gif</profile_background_image_url>
<profile_background_tile>false</profile_background_tile>
    <statuses_count>2469</statuses_count>
    <notifications></notifications>
    <verified>false</verified>
    <following></following>
  </user>
</status>
</pre>
<p>How did I get this? Get yourself a curl utility (if you on Win you can use <a href="http://curl.haxx.se/">this one</a>) and run this command from the command prompt</p>
<pre>% curl http://stream.twitter.com/spritzer.xml -uYOURUSERNAME:YOURPASSWORD</pre>
<p>Note that <em>YOURUSERNAME:YOURPASSWORD</em> is just your regular Twitter user name/password &#8211; you don&#8217;t need to register dev account, nothing like that<br />
You will now see long stream of XML snippets like one above. Change to spritzer.json and now you are streaming JSON</p>
<p>What to do with this? Hey &#8211; I have some ideas, you can get your own</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.bostone.us/2009/07/31/spritzer-your-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DroidIn 1.2.1 &#8211; LinkedIn meets Twitter</title>
		<link>http://dev.bostone.us/2009/07/17/droidin-1-2-1-linkedin-meets-twitter/</link>
		<comments>http://dev.bostone.us/2009/07/17/droidin-1-2-1-linkedin-meets-twitter/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 20:50:20 +0000</pubDate>
		<dc:creator>bostone</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web stuff]]></category>

		<guid isPermaLink="false">http://dev.bostone.us/?p=212</guid>
		<description><![CDATA[I released v. 1.2 of DroidIn &#8211; Android LinkedIn client. It has ability now to post updates to Twitter anytime you update status in LinkedIn. Details are at http://droidin.net
]]></description>
			<content:encoded><![CDATA[<p>I released v. 1.2 of DroidIn &#8211; Android LinkedIn client. It has ability now to post updates to Twitter anytime you update status in LinkedIn. Details are at <a href="http://droidin.net/2009/07/15/droidin-linkedin-meets-twitter/">http://droidin.net</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dev.bostone.us/2009/07/17/droidin-1-2-1-linkedin-meets-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android &#8211; OAuth updates to Twitter</title>
		<link>http://dev.bostone.us/2009/07/16/android-oauth-twitter-updates/</link>
		<comments>http://dev.bostone.us/2009/07/16/android-oauth-twitter-updates/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 00:24:39 +0000</pubDate>
		<dc:creator>bostone</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web stuff]]></category>
		<category><![CDATA[oauth]]></category>

		<guid isPermaLink="false">http://dev.bostone.us/?p=194</guid>
		<description><![CDATA[In the spirit of community giving here&#8217;s step by step tutorial on how to do OAuth Twitter status updates on Android
Prerequisites
I&#8217;m using most excellent oauth-signpost library for this tutorial. You will need both core and commonshttp4 jars which you should simply drop into your project/assets folder and add to your Eclipse&#8217;s build path
Register App
Go and [...]]]></description>
			<content:encoded><![CDATA[<p>In the spirit of community giving here&#8217;s step by step tutorial on how to do OAuth Twitter status updates on Android</p>
<h4>Prerequisites</h4>
<p>I&#8217;m using most excellent <a href="http://code.google.com/p/oauth-signpost/">oauth-signpost</a> library for this tutorial. You will need both core and commonshttp4 jars which you should simply drop into your project/assets folder and add to your Eclipse&#8217;s build path</p>
<h4>Register App</h4>
<p>Go and <a href="http://twitter.com/oauth_clients/new">register</a> your new wonderful app on Twitter. When filling the form don&#8217;t forget to choose &#8220;browser&#8221; as &#8220;Application Type&#8221;. If you fail to do that or if your current app doesn&#8217;t have that option selected then you won&#8217;t be able to redirect back to your Android app after Twitter authorization step. The form asks for &#8220;Callback URL&#8221;, you can enter any valid URL doesn&#8217;t matter which one since you will provide the &#8220;real&#8221; one programmatically.<br />
Note &#8220;Consumer key&#8221; and &#8220;Consumer secret&#8221; values &#8211; you will need these in your app</p>
<h4>Common code</h4>
<p>Create consumer and provider where you see fit so you can reuse these later</p>
<pre class="java" name="code">
    CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(
            CONSUMER_KEY, CONSUMER_SECRET, SignatureMethod.HMAC_SHA1);

    OAuthProvider provider = new DefaultOAuthProvider(consumer,
            "http://twitter.com/oauth/request_token", "http://twitter.com/oauth/access_token",
            "http://twitter.com/oauth/authorize");
    HttpClient client = new DefaultHttpClient();
</pre>
<h4>Authorization</h4>
<p>Create some sort of trigger in your Android app such as checkbox &#8220;Enable Twitter&#8221;. When user triggers it the following should happen in your code</p>
<pre name="code" class="java">
// Context ctx whichever way you passing it in
String authUrl = provider.retrieveRequestToken(CALLBACK_URL);
ctx.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
</pre>
<p>Now &#8211; the CALLBACK_URL would be something like <strong>yourapp://twitt</strong> and basically it will be loaded by external browser if authentication/authorization is successful<br />
So what will happen when this code is executed? The external browser will come up and display Twitter&#8217;s &#8220;Authorize Application Access&#8221; page. When user logs in and clicks &#8220;Allow&#8221; you should see message telling you that permission is granted and you will be redirected back.</p>
<h4>Back from authorization</h4>
<p>For your app to pick that app here are next steps<br />
Add intent filter<br />
Open AndroidManifest.xml and add the following lines to the activity that you want to handle further processing</p>
<pre name="code" class="xml">
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="yourapp" android:host="twitt"></data>
</intent-filter>
</pre>
<p>Note &#8220;data&#8221; element &#8211; scheme and host should match your callback URL (remember <strong>yourapp://twitt</strong>?)<br />
In Android when browser calls that callback URL then your app is brought forward and activity&#8217;s onResume() method is called. So in that method you should place the following code that basically gets you token and token_secret</p>
<pre name="code" class="java">
// this must be places in activity#onResume()
Uri uri = this.getIntent().getData();
if (uri != null &#038;&#038; uri.toString().startsWith(CALLBACK_URL)) {
    String verifier = uri.getQueryParameter(OAUTH_VERIFIER);
    // this will populate token and token_secret in consumer
    provider.retrieveAccessToken(verifier);
}
</pre>
<p>At this point you can call consumet#getToken() and consumer#getTokenSecret() to get and save token/secret for subsequent calls. According to Twitter &#8211; access token will not expire unless revoked by user</p>
<h4>Posting update</h4>
<p>Well, congrats &#8211; if you were able to execute all the steps above you now ready to post your first update. Here&#8217;s the code that will do it</p>
<pre name="code" class="java">
        // create a request that requires authentication
        HttpPost post = new HttpPost("http://twitter.com/statuses/update.xml");
        final List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        // 'status' here is the update value you collect from UI
        nvps.add(new BasicNameValuePair("status", status));
        post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
        // set this to avoid 417 error (Expectation Failed)
        post.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
        // sign the request
        consumer.sign(post);
        // send the request
        final HttpResponse response = client.execute(post);
        // response status should be 200 OK
        int statusCode = response.getStatusLine().getStatusCode();
        final String reason = response.getStatusLine().getReasonPhrase();
        // release connection
        response.getEntity().consumeContent();
        if (statusCode != 200) {
            Log.e("TwitterConnector", reason);
            throw new OAuthNotAuthorizedException();
        }
</pre>
<p>Now &#8211; you can use different update URL to get JSON for example, but generally you can use code above to sign any of your Twitter requests.<br />
Happy Twitting!!</p>
<p>P.S. If you decide to re-post this article please kindly provide link back to the original. And if you have Android phone checkout <a href="http://droidin.net">DroidIn </a>- LinkedIn app.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.bostone.us/2009/07/16/android-oauth-twitter-updates/feed/</wfw:commentRss>
		<slash:comments>53</slash:comments>
		</item>
	</channel>
</rss>
