<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title>Coffee Cup</title>
	
	<link>http://www.thewiredguy.com/wordpress</link>
	<description>Code with a cup of coffee</description>
	<lastBuildDate>Sat, 28 Nov 2009 23:52:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TheWiredGuy" /><feedburner:info uri="thewiredguy" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Cross-Domain requests in Silverlight and using Yahoo Pipes as a proxy</title>
		<link>http://feedproxy.google.com/~r/TheWiredGuy/~3/kak3VM8a-14/</link>
		<comments>http://www.thewiredguy.com/wordpress/?p=68#comments</comments>
		<pubDate>Sat, 28 Nov 2009 23:11:12 +0000</pubDate>
		<dc:creator>sanil</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Social Apps]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">http://www.thewiredguy.com/wordpress/?p=68</guid>
		<description><![CDATA[Last week, I have been developing this silverlight twitter application and was struck at a point, where I needed to pull RSS feeds from twitter. The code will always throw a Security Exception again and again. After digging a bit, I found out that silverlight doesn&#8217;t allow cross-domain calls to any domain you want.
This policy [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, I have been developing this silverlight twitter application and was struck at a point, where I needed to pull RSS feeds from twitter. The code will always throw a <a href="http://forums.silverlight.net/forums/t/11099.aspx" target="_blank">Security Exception</a> again and again. After digging a bit, I found out that silverlight doesn&#8217;t allow cross-domain calls to any domain you want.</p>
<p>This policy has been enforced to prevent <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery" target="_blank">session riding</a>, for further details look this Karen Corby&#8217;s <a href="http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/" target="_blank">blog post</a> on cross domain requests.</p>
<p>Turns out that in silverlight, HTTP requests to non-original domains are allowed if the server has exclusively allowed to accept requests. The primary way of enabling cross domain calls is through a policy file placed at the root of the server.&nbsp; Two types of policy files are supported:</p>
<ol>
<li>Silverlight Cross Domain Policy File (clientaccesspolicy.xml)
<li>(A subset of the) Flash Cross Domain Policy File (crossdomain.xml)</li>
</ol>
<p>Now, the problem is that twitter don&#8217;t have policy files placed in the server root. Possible way to get around this is to use a proxy for requests. you can make a proxy on your server, that can on application request, fetch the RSS data from twitter and send it back to your application. EASY!</p>
<p>but what if, you don&#8217;t want your own server proxy&#8230; </p>
<p><strong>reasons</strong>:</p>
<ul>
<li>you will have to add a policy file to your server root
<li>that will cause increase in the server bandwidth usage and server stress
<li>it&#8217;s hell lot of work</li>
</ul>
<p>simple! use <a href="http://pipes.yahoo.com" target="_blank">Yahoo Pipes</a>, why?</p>
<ul>
<li>Its easy
<li>because, they allow you to request RSS feeds from other sites (multiple sites in one request)
<li>they have cross-domain policy files placed on there server roots, that means your silverlight application will be able to fetch the Twitter data via a yahoo pipe</li>
</ul>
<p><u>What is a yahoo pipe?</u></p>
<blockquote><p><strong>Content-source</strong>: <a title="http://pipes.yahoo.com/pipes/" href="http://pipes.yahoo.com/pipes/">http://pipes.yahoo.com/pipes/</a>
<p>Pipes is a powerful composition tool to aggregate, manipulate, and mashup content from around the web.
<p>Like Unix pipes, simple commands can be combined together to create output that meets your needs:
<ul>
<li>combine many feeds into one, then sort, filter and translate it.
<li>geocode your favorite feeds and browse the items on an interactive map.
<li>power widgets/badges on your web site.
<li>grab the output of any Pipes as RSS, JSON, KML, and other formats. </li>
</ul>
</blockquote>
<p>simply speaking, a yahoo pipe is url like this:</p>
<p><a title="http://pipes.yahoo.com/pipes/pipe.info?_id=f0cf1b0851bd8243dbf8bd63c07b8d11" href="http://pipes.yahooapis.com/pipes/pipe.info?_id=bas782j290jq9dd2nmaklfhj93ji9d3j">http://pipes.<strong>yahooapis</strong>.com/pipes/pipe.info?_id=bas782j290jq9dd2nmaklfhj93ji9d3j</a></p>
<p>you design its behaviour on a design surface </p>
<p><a href="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image_thumb.png" width="752" height="454"></a> </p>
<p>So, a yahoo pipe can be designed to take single/multiple feed URLs, fetch the feeds and provide an aggregated feed which can be consumed by your silverlight application under cross domain policy.</p>
<p>further, you can provide test data and see results right there.</p>
<p>Run it and get the aggregated RSS URL from the run screen.</p>
<p>The pipe, I used looks like this</p>
<p>http://pipes.yahooapis.com/pipes/pipe.run?_id=f0cf1b0851bd8243dbf8bd63c07b8d11&amp;_render=rss&amp;feedUrl=&lt;some_feed_url&gt;</p>
<p><a href="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image_3.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image_thumb_3.png" width="452" height="310"></a> </p>
<p>Now fetching the data in your silverlight application is damn easy&#8230;</p>
<p>&nbsp;</p>
<pre class="csharpcode"><span class="kwrd">private</span> <span class="kwrd">string</span> proxy = <span class="str">"http://pipes.yahooapis.com/pipes/pipe.run?_id=f0cf1b0851bd8243dbf8bd63c07b8d11&amp;_render=rss&amp;feedUrl="</span>;
<span class="kwrd">private</span> <span class="kwrd">string</span> feedUrl = <span class="str">"http://twitter.com/statuses/user_timeline/22100709.rss"</span>;
<span class="kwrd">void</span> DownloadFeed()
{
            <span class="kwrd">string</span> url = proxy + feedUrl;
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(<span class="kwrd">new</span> Uri(url));
            request.Method = <span class="str">"GET"</span>;
            request.BeginGetResponse(<span class="kwrd">new</span> AsyncCallback(ResponseHandler), request);
}
<span class="kwrd">void</span> ResponseHandler(IAsyncResult asyncResult)
{
            <span class="kwrd">try</span>
            {
                HttpWebRequest request = (HttpWebRequest)asyncResult.AsyncState;
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asyncResult);
                <span class="kwrd">if</span> (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream stream = response.GetResponseStream();
                    <span class="kwrd">int</span> len = 1024;
                    <span class="kwrd">byte</span>[] buf = <span class="kwrd">new</span> <span class="kwrd">byte</span>[len];
                    <span class="kwrd">int</span> read = 0;
                    xml = <span class="str">""</span>;
                    <span class="kwrd">do</span>
                    {
                        read = stream.Read(buf, 0, len);
                        xml += Encoding.UTF8.GetString(buf, 0, read);
                    }<span class="kwrd">while</span> (read &gt; 0);
                    stream.Close();
                    ParseRSSFeed(xml);
                }
            }
            <span class="kwrd">catch</span> (System.Security.SecurityException ex)
            {
                <span class="rem">// Do Something</span>
            }
 }</pre>
<pre class="csharpcode">&nbsp;</pre>
<pre class="csharpcode">Next, you can include Linq to Xml (add System.Xml.Linq to References) to easily and quickly parse the xml to fetch the user tweets. </pre>
<pre class="csharpcode">You can read more about that on Scott Gu's blog post: <a href="http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-3-using-networking-to-retrieve-data-and-populate-a-datagrid.aspx" target="_blank">Silverlight Tutorial Part 3: Using Networking to Retrieve Data and Populate a DataGrid</a></pre>
<pre class="csharpcode">Here is, how I have done it:</pre>
<pre class="csharpcode">The feed  you get from twitter will look like this:</pre>
<pre class="csharpcode"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">="1.0"</span> <span class="attr">encoding</span><span class="kwrd">="utf-16"</span>?<span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">rss</span> <span class="attr">xmlns:atom</span><span class="kwrd">="http://www.w3.org/2005/Atom"</span> <span class="attr">version</span><span class="kwrd">="2.0"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">channel</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>Twitter / LON3WOLF<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">link</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF<span class="kwrd">&lt;/</span><span class="html">link</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">atom:link</span> <span class="attr">type</span><span class="kwrd">="application/rss+xml"</span> <span class="attr">href</span><span class="kwrd">="http://twitter.com/statuses/user_timeline/22100709.rss"</span> <span class="attr">rel</span><span class="kwrd">="self"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">description</span><span class="kwrd">&gt;</span>Twitter updates from Sanil Singh Tomar / LON3WOLF.<span class="kwrd">&lt;/</span><span class="html">description</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">language</span><span class="kwrd">&gt;</span>en-us<span class="kwrd">&lt;/</span><span class="html">language</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">ttl</span><span class="kwrd">&gt;</span>40<span class="kwrd">&lt;/</span><span class="html">ttl</span><span class="kwrd">&gt;</span>
           <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>LON3WOLF: ehem... RT @Zee: awww man...RT @patrick Best toilet ever! http://twitpic.com/rcvp2 #fb<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">item</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai you mean one that looks like xkcd, if you find any tool 4 that, then please RT <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">description</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai you mean one that looks like xkcd<span class="kwrd">&lt;/</span><span class="html">description</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>Sat, 28 Nov 2009 16:40:22 +0000<span class="kwrd">&lt;/</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">guid</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6144843401<span class="kwrd">&lt;/</span><span class="html">guid</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">link</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6144843401<span class="kwrd">&lt;/</span><span class="html">link</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">item</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">item</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai Go to ' Block ' button-<span class="attr">&amp;amp;</span>gt; Click! Click! <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">description</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai Go to ' Block ' button-<span class="attr">&amp;amp;</span>gt; Click! Click! <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span class="kwrd">&lt;/</span><span class="html">description</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>Fri, 27 Nov 2009 18:38:03 +0000<span class="kwrd">&lt;/</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">guid</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6119125496<span class="kwrd">&lt;/</span><span class="html">guid</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">link</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6119125496<span class="kwrd">&lt;/</span><span class="html">link</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">item</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">channel</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">rss</span><span class="kwrd">&gt;</span></pre>
<pre class="csharpcode"><span class="kwrd"><font color="#000000">You can use Linq to XML in following way:</font></span></pre>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> item
{
        <span class="kwrd">public</span> <span class="kwrd">string</span> title;
        <span class="kwrd">public</span> <span class="kwrd">string</span> description;
        <span class="kwrd">public</span> <span class="kwrd">string</span> pubDate;
        <span class="kwrd">public</span> <span class="kwrd">string</span> guid;
        <span class="kwrd">public</span> <span class="kwrd">string</span> link;
}
<span class="kwrd">public</span> <span class="kwrd">void</span> ParseRSSFeed(<span class="kwrd">string</span> xmlContent)
 {
            XDocument rss = XDocument.Parse(xmlContent);
            var tweets = from feed <span class="kwrd">in</span> rss.Descendants(<span class="str">"channel"</span>).Descendants(<span class="str">"item"</span>)
                        select <span class="kwrd">new</span> item
                        {
                            guid = (<span class="kwrd">string</span>) feed.Element(<span class="str">"guid"</span>),
                            pubDate = (<span class="kwrd">string</span>)feed.Element(<span class="str">"pubDate"</span>),
                            title = (<span class="kwrd">string</span>)feed.Element(<span class="str">"title"</span>),
                            description = (<span class="kwrd">string</span>)feed.Element(<span class="str">"description"</span>),
                            link = (<span class="kwrd">string</span>)feed.Element(<span class="str">"link"</span>)
                        };
            Status = <span class="kwrd">new</span> item[tweets.Count()];
            <span class="rem">//Copy description to status</span>
            <span class="kwrd">int</span> count = 0;
            <span class="kwrd">foreach</span> (var tweet <span class="kwrd">in</span> tweets)
            {
                Status[count] = tweet;
                count++;
            }
 }</pre>
<pre class="csharpcode"><strong>Links:</strong></pre>
<p><a href="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/page_white_swoosh.png"><img border="0" alt="page_white_swoosh" src="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/page_white_swoosh_thumb.png" width="16" height="16"></a> Source Code: <a href="http://thewiredguy.com/Codegarage/?p=109">Download</a> </p>
<p><a href="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/application_link.png"><img border="0" alt="application_link" src="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/application_link_thumb.png" width="16" height="16"></a> Application: <a href="http://thewiredguy.com/Codegarage/?p=109">Download</a></p>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<div id="flaresmith" class="feedflare"><script src="http://feeds.feedburner.com/~s/thewiredguy?i=http://www.thewiredguy.com/wordpress/?p=68" type="text/javascript" charset="utf-8"></script></div><img src="http://feeds.feedburner.com/~r/TheWiredGuy/~4/kak3VM8a-14" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thewiredguy.com/wordpress/?feed=rss2&amp;p=68</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.thewiredguy.com/wordpress/?p=68</feedburner:origLink></item>
		<item>
		<title>Cross-Domain requests in Silverlight and using Yahoo Pipes as a proxy</title>
		<link>http://feedproxy.google.com/~r/TheWiredGuy/~3/BWoaEflX4Vk/</link>
		<comments>http://www.thewiredguy.com/wordpress/?p=65#comments</comments>
		<pubDate>Sat, 28 Nov 2009 23:11:12 +0000</pubDate>
		<dc:creator>sanil</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Social Apps]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">http://www.thewiredguy.com/wordpress/?p=65</guid>
		<description><![CDATA[Last week, I have been developing this silverlight twitter application and was struck at a point, where I needed to pull RSS feeds from twitter. The code will always throw a Security Exception again and again. After digging a bit, I found out that silverlight doesn&#8217;t allow cross-domain calls to any domain you want.
This policy [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, I have been developing this silverlight twitter application and was struck at a point, where I needed to pull RSS feeds from twitter. The code will always throw a <a href="http://forums.silverlight.net/forums/t/11099.aspx" target="_blank">Security Exception</a> again and again. After digging a bit, I found out that silverlight doesn&#8217;t allow cross-domain calls to any domain you want.</p>
<p>This policy has been enforced to prevent <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery" target="_blank">session riding</a>, for further details look this Karen Corby&#8217;s <a href="http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/" target="_blank">blog post</a> on cross domain requests.</p>
<p>Turns out that in silverlight, HTTP requests to non-original domains are allowed if the server has exclusively allowed to accept requests. The primary way of enabling cross domain calls is through a policy file placed at the root of the server.&nbsp; Two types of policy files are supported:</p>
<ol>
<li>Silverlight Cross Domain Policy File (clientaccesspolicy.xml) </li>
<li>(A subset of the) Flash Cross Domain Policy File (crossdomain.xml)</li>
</ol>
<p>Now, the problem is that twitter don&#8217;t have policy files placed in the server root. Possible way to get around this is to use a proxy for requests. you can make a proxy on your server, that can on application request, fetch the RSS data from twitter and send it back to your application. EASY!</p>
<p>but what if, you don&#8217;t want your own server proxy&#8230; </p>
<p><strong>reasons</strong>:</p>
<ul>
<li>you will have to add a policy file to your server root
<li>that will cause increase in the server bandwidth usage and server stress
<li>it&#8217;s hell lot of work</li>
</ul>
<p>simple! use <a href="http://pipes.yahoo.com" target="_blank">Yahoo Pipes</a>, why?</p>
<ul>
<li>Its easy
<li>because, they allow you to request RSS feeds from other sites (multiple sites in one request)
<li>they have cross-domain policy files placed on there server roots, that means your silverlight application will be able to fetch the Twitter data via a yahoo pipe</li>
</ul>
<p><u>What is a yahoo pipe?</u></p>
<blockquote><p><strong>Content-source</strong>: <a title="http://pipes.yahoo.com/pipes/" href="http://pipes.yahoo.com/pipes/">http://pipes.yahoo.com/pipes/</a>
<p>Pipes is a powerful composition tool to aggregate, manipulate, and mashup content from around the web.
<p>Like Unix pipes, simple commands can be combined together to create output that meets your needs:
<ul>
<li>combine many feeds into one, then sort, filter and translate it.
<li>geocode your favorite feeds and browse the items on an interactive map.
<li>power widgets/badges on your web site.
<li>grab the output of any Pipes as RSS, JSON, KML, and other formats. </li>
</ul>
<p>simply speaking, a yahoo pipe is url like this:</p>
</blockquote>
<p><a title="http://pipes.yahoo.com/pipes/pipe.info?_id=f0cf1b0851bd8243dbf8bd63c07b8d11" href="http://pipes.yahooapis.com/pipes/pipe.info?_id=bas782j290jq9dd2nmaklfhj93ji9d3j">http://pipes.<strong>yahooapis</strong>.com/pipes/pipe.info?_id=bas782j290jq9dd2nmaklfhj93ji9d3j</a></p>
<p>you design its behaviour on a design surface </p>
<p><a href="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image_thumb.png" width="752" height="454"></a> </p>
<p>So, a yahoo pipe can be designed to take single/multiple feed URLs, fetch the feeds and provide an aggregated feed which can be consumed by your silverlight application under cross domain policy.</p>
<p>further, you can provide test data and see results right there.</p>
<p>Run it and get the aggregated RSS URL from the run screen.</p>
<p>The pipe, I used looks like this</p>
<p>http://pipes.yahooapis.com/pipes/pipe.run?_id=f0cf1b0851bd8243dbf8bd63c07b8d11&amp;_render=rss&amp;feedUrl=&lt;some_feed_url&gt;</p>
<p><a href="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image_3.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image_thumb_3.png" width="452" height="310"></a> </p>
<p>Now fetching the data in your silverlight application is damn easy&#8230;</p>
<p>&nbsp;</p>
<pre class="csharpcode"><span class="kwrd">private</span> <span class="kwrd">string</span> proxy = <span class="str">"http://pipes.yahooapis.com/pipes/pipe.run?_id=f0cf1b0851bd8243dbf8bd63c07b8d11&amp;_render=rss&amp;feedUrl="</span>;
<span class="kwrd">private</span> <span class="kwrd">string</span> feedUrl = <span class="str">"http://twitter.com/statuses/user_timeline/22100709.rss"</span>;
<span class="kwrd">void</span> DownloadFeed()
{
            <span class="kwrd">string</span> url = proxy + feedUrl;
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(<span class="kwrd">new</span> Uri(url));
            request.Method = <span class="str">"GET"</span>;
            request.BeginGetResponse(<span class="kwrd">new</span> AsyncCallback(ResponseHandler), request);
}
<span class="kwrd">void</span> ResponseHandler(IAsyncResult asyncResult)
{
            <span class="kwrd">try</span>
            {
                HttpWebRequest request = (HttpWebRequest)asyncResult.AsyncState;
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asyncResult);
                <span class="kwrd">if</span> (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream stream = response.GetResponseStream();
                    <span class="kwrd">int</span> len = 1024;
                    <span class="kwrd">byte</span>[] buf = <span class="kwrd">new</span> <span class="kwrd">byte</span>[len];
                    <span class="kwrd">int</span> read = 0;
                    xml = <span class="str">""</span>;
                    <span class="kwrd">do</span>
                    {
                        read = stream.Read(buf, 0, len);
                        xml += Encoding.UTF8.GetString(buf, 0, read);
                    }<span class="kwrd">while</span> (read &gt; 0);
                    stream.Close();
                    ParseRSSFeed(xml);
                }
            }
            <span class="kwrd">catch</span> (System.Security.SecurityException ex)
            {
                <span class="rem">// Do Something</span>
            }
 }</pre>
<pre class="csharpcode">&nbsp;</pre>
<pre class="csharpcode">Next, you can include Linq to Xml (add System.Xml.Linq to References) to easily and quickly parse the xml to fetch the user tweets. </pre>
<pre class="csharpcode">You can read more about that on Scott Gu's blog post: <a href="http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-3-using-networking-to-retrieve-data-and-populate-a-datagrid.aspx" target="_blank">Silverlight Tutorial Part 3: Using Networking to Retrieve Data and Populate a DataGrid</a></pre>
<pre class="csharpcode">Here is, how I have done it:</pre>
<pre class="csharpcode">The feed  you get from twitter will look like this:</pre>
<pre class="csharpcode"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">="1.0"</span> <span class="attr">encoding</span><span class="kwrd">="utf-16"</span>?<span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">rss</span> <span class="attr">xmlns:atom</span><span class="kwrd">="http://www.w3.org/2005/Atom"</span> <span class="attr">version</span><span class="kwrd">="2.0"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">channel</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>Twitter / LON3WOLF<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">link</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF<span class="kwrd">&lt;/</span><span class="html">link</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">atom:link</span> <span class="attr">type</span><span class="kwrd">="application/rss+xml"</span> <span class="attr">href</span><span class="kwrd">="http://twitter.com/statuses/user_timeline/22100709.rss"</span> <span class="attr">rel</span><span class="kwrd">="self"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">description</span><span class="kwrd">&gt;</span>Twitter updates from Sanil Singh Tomar / LON3WOLF.<span class="kwrd">&lt;/</span><span class="html">description</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">language</span><span class="kwrd">&gt;</span>en-us<span class="kwrd">&lt;/</span><span class="html">language</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">ttl</span><span class="kwrd">&gt;</span>40<span class="kwrd">&lt;/</span><span class="html">ttl</span><span class="kwrd">&gt;</span>
           <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>LON3WOLF: ehem... RT @Zee: awww man...RT @patrick Best toilet ever! http://twitpic.com/rcvp2 #fb<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">item</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai you mean one that looks like xkcd, if you find any tool 4 that, then please RT <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">description</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai you mean one that looks like xkcd<span class="kwrd">&lt;/</span><span class="html">description</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>Sat, 28 Nov 2009 16:40:22 +0000<span class="kwrd">&lt;/</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">guid</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6144843401<span class="kwrd">&lt;/</span><span class="html">guid</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">link</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6144843401<span class="kwrd">&lt;/</span><span class="html">link</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">item</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">item</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai Go to ' Block ' button-<span class="attr">&amp;amp;</span>gt; Click! Click! <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">description</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai Go to ' Block ' button-<span class="attr">&amp;amp;</span>gt; Click! Click! <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span class="kwrd">&lt;/</span><span class="html">description</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>Fri, 27 Nov 2009 18:38:03 +0000<span class="kwrd">&lt;/</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">guid</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6119125496<span class="kwrd">&lt;/</span><span class="html">guid</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">link</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6119125496<span class="kwrd">&lt;/</span><span class="html">link</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">item</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">channel</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">rss</span><span class="kwrd">&gt;</span></pre>
<pre class="csharpcode"><span class="kwrd"><font color="#000000">You can use Linq to XML in following way:</font></span></pre>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> item
{
        <span class="kwrd">public</span> <span class="kwrd">string</span> title;
        <span class="kwrd">public</span> <span class="kwrd">string</span> description;
        <span class="kwrd">public</span> <span class="kwrd">string</span> pubDate;
        <span class="kwrd">public</span> <span class="kwrd">string</span> guid;
        <span class="kwrd">public</span> <span class="kwrd">string</span> link;
}
<span class="kwrd">public</span> <span class="kwrd">void</span> ParseRSSFeed(<span class="kwrd">string</span> xmlContent)
 {
            XDocument rss = XDocument.Parse(xmlContent);
            var tweets = from feed <span class="kwrd">in</span> rss.Descendants(<span class="str">"channel"</span>).Descendants(<span class="str">"item"</span>)
                        select <span class="kwrd">new</span> item
                        {
                            guid = (<span class="kwrd">string</span>) feed.Element(<span class="str">"guid"</span>),
                            pubDate = (<span class="kwrd">string</span>)feed.Element(<span class="str">"pubDate"</span>),
                            title = (<span class="kwrd">string</span>)feed.Element(<span class="str">"title"</span>),
                            description = (<span class="kwrd">string</span>)feed.Element(<span class="str">"description"</span>),
                            link = (<span class="kwrd">string</span>)feed.Element(<span class="str">"link"</span>)
                        };
            Status = <span class="kwrd">new</span> item[tweets.Count()];
            <span class="rem">//Copy description to status</span>
            <span class="kwrd">int</span> count = 0;
            <span class="kwrd">foreach</span> (var tweet <span class="kwrd">in</span> tweets)
            {
                Status[count] = tweet;
                count++;
            }
 }</pre>
<pre class="csharpcode"><strong>Links:</strong></pre>
<p><a href="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/page_white_swoosh.png"><img border="0" alt="page_white_swoosh" src="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/page_white_swoosh_thumb.png" width="16" height="16"></a> Source Code: <a href="http://thewiredguy.com/Codegarage/?p=109">Download</a></p>
<p><a href="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/application_link.png"><img border="0" alt="application_link" src="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/application_link_thumb.png" width="16" height="16"></a> Application: <a href="http://thewiredguy.com/Codegarage/?p=109">Download</a></p>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<div id="flaresmith" class="feedflare"><script src="http://feeds.feedburner.com/~s/thewiredguy?i=http://www.thewiredguy.com/wordpress/?p=65" type="text/javascript" charset="utf-8"></script></div><img src="http://feeds.feedburner.com/~r/TheWiredGuy/~4/BWoaEflX4Vk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thewiredguy.com/wordpress/?feed=rss2&amp;p=65</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.thewiredguy.com/wordpress/?p=65</feedburner:origLink></item>
		<item>
		<title>Presenting Code Garage</title>
		<link>http://feedproxy.google.com/~r/TheWiredGuy/~3/VJLTSa4utxA/</link>
		<comments>http://www.thewiredguy.com/wordpress/?p=63#comments</comments>
		<pubDate>Sun, 15 Nov 2009 04:37:04 +0000</pubDate>
		<dc:creator>sanil</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Fun, April Fool, Prank]]></category>
		<category><![CDATA[Open Source]]></category>
		<guid isPermaLink="false">http://www.thewiredguy.com/wordpress/?p=63</guid>
		<description><![CDATA[
&#160;
Presenting Code Garage
&#160;
&#160;
We all (The Programmers) write handy tools and other hell things that can make our life easier (or harder). We don&#8217;t mind it sharing it with others. They are tiny apps/utilities created just for fun or some serious job, made in free time when some idea strikes you.
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
With the idea of sharing those [...]]]></description>
			<content:encoded><![CDATA[<h1><a href="http://www.thewiredguy.com/codegarage"><img style="margin: 5px" align="left" src="http://thewiredguy.com/Codegarage/wp-content/themes/inanis-glass/images/blogicon.png" width="127" height="136"></a></h1>
<h1>&nbsp;</h1>
<h1>Presenting Code Garage</h1>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>We all (The Programmers) write handy tools and other hell things that can make our life easier (or harder). We don&#8217;t mind it sharing it with others. They are tiny apps/utilities created just for fun or some serious job, made in free time when some idea strikes you.</p>
<p><a href="http://www.thewiredguy.com/codegarage"><img style="margin: 5px" border="0" alt="image" align="left" src="http://thewiredguy.com/BlogImages/PresentingCodeGarage_8D99/image_thumb.png" width="319" height="202"></a>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>With the idea of sharing those utilities and source code, here I am presenting <a href="http://www.thewiredguy.com/codegarage"><strong>Code Garage</strong></a>. Here you can download the applications or use the Source Code, in a way you want.</p>
<p><strong><u>License??</u></strong></p>
<p>Oh! yes it does comes with a license, its WTFPL.</p>
<p><strong><u>What is that??</u></strong></p>
<p><u><a href="http://thewiredguy.com/Codegarage/License.txt" target="_blank">WTFPL</a></u> : Do What The Fuck You Want Public License. (here is <a href="http://sam.zoy.org/wtfpl/" target="_blank">original link</a> )</p>
<p><strong><u>Seriously, What&#8217;s that?</u></strong></p>
<p>Well, here is how it&nbsp; binds you:</p>
<blockquote><pre>  DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004
 Copyright (C) 2004 Sam Hocevar
  14 rue de Plaisance, 75014 Paris, France
 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.
            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  0. You just DO WHAT THE FUCK YOU WANT TO.</pre>
</blockquote>
<p>In Summary: You can do whatever you want, you are <strong><u>FREE!</u></strong></p>
<p><strong>Q: <u>Can I do that?</u></strong></p>
<p>A: yes, you can</p>
<p><strong>Q: <u>And that?</u></strong></p>
<p>A: duh! Yes <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p><strong>Q: <u>Can I add my code here?</u></strong></p>
<p>A: Yes you can, though I would like to see an entire your own blog dedicated to that. but, still if you want you are welcome, just send me an <a href="mailto:sanil.sun@gmail.com" target="_blank">email</a></p>
<p><strong>Last Word</strong>: I hold no liabilities, if you happen to use any code/utilities from here and something bad happens to you, including any loss incurred in any form. That means I am free too from any liabilities, you can&#8217;t sue me in anyway.</p>
<p>Said that, here is a list of the utilities/source code etc that I have uploaded and published plus those that I plan to upload:</p>
<ul>
<li>SMTP</li>
<li>Alarm</li>
<li>Processviewer</li>
<li>BookStore</li>
<li>CDStore</li>
<li>VinkrIt gadget</li>
<li>BSoD</li>
<li>A-Z</li>
<li>Search Plugin</li>
<li>DNS Query</li>
<li>Desktop Shock </li>
<li>batch &amp; Regs</li>
<li>Desktop Draw</li>
<li>Chronometer</li>
<li>Search Gadget</li>
<li>Pagination Extension</li>
<li>Crazy drive</li>
<li>MOaB</li>
<li>Keyboard logger</li>
<li>xKernel</li>
<li>TCP Socket demo for unix</li>
<li>basic java car anim</li>
<li>Expense Reporter</li>
</ul>
<p>Yeah! it covers lamest things, I happen to write.</p>
<p>Still have questions?</p>
<div id="flaresmith" class="feedflare"><script src="http://feeds.feedburner.com/~s/thewiredguy?i=http://www.thewiredguy.com/wordpress/?p=63" type="text/javascript" charset="utf-8"></script></div><img src="http://feeds.feedburner.com/~r/TheWiredGuy/~4/VJLTSa4utxA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thewiredguy.com/wordpress/?feed=rss2&amp;p=63</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.thewiredguy.com/wordpress/?p=63</feedburner:origLink></item>
		<item>
		<title>Just another way to analyse code behaviour – In my humble opinion</title>
		<link>http://feedproxy.google.com/~r/TheWiredGuy/~3/nKFCMF_XjlM/</link>
		<comments>http://www.thewiredguy.com/wordpress/?p=62#comments</comments>
		<pubDate>Sat, 14 Nov 2009 19:52:26 +0000</pubDate>
		<dc:creator>sanil</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding Fundamentals]]></category>
		<guid isPermaLink="false">http://www.thewiredguy.com/wordpress/?p=62</guid>
		<description><![CDATA[Last week, a good friend of mine posted a question on his blog, which track backs to Eric Lippert&#8217;s blog post Simple names are not so simple.
Side Note: I am big fan of that blog, its awesome and enlightening
Well, here is an excerpt of that post:
Check out the code below:
using System.Linq;    [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, a good <a href="http://www.facebook.com/kinnarshah" target="_blank">friend</a> of mine posted a question on his <a href="http://www.kinnarshah.in/index.php/2009/11/04/interesting-linq-problem/" target="_blank">blog</a>, which track backs to <a href="http://blogs.msdn.com/ericlippert/archive/2009/11/02/simple-names-are-not-so-simple.aspx" target="_blank">Eric Lippert&#8217;s</a> blog post <a href="http://blogs.msdn.com/ericlippert/archive/2009/11/02/simple-names-are-not-so-simple.aspx">Simple names are not so simple</a>. </p>
<p><u>Side Note</u>: I am big fan of that blog, its awesome and enlightening</p>
<p>Well, here is an excerpt of that post:</p>
<blockquote><p>Check out the code below:</p>
<p>using System.Linq;      <br />class Program       <br />{       <br />&#160; static void Main()       <br />&#160; {&#160; <br />&#160;&#160;&#160;&#160;&#160; int[] data = { 1, 2, 3, 1, 2, 1 };       <br />&#160;&#160;&#160;&#160;&#160; foreach (<strong>var m in from m in data orderby m select m</strong>)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.Console.Write(m);       <br />&#160; }       <br />}</p>
<p><a href="http://www.kinnarshah.in/wp-content/uploads/2009/11/frustration3.jpg"><img title="frustration3" border="0" alt="frustration3" align="left" src="http://www.kinnarshah.in/wp-content/uploads/2009/11/frustration3_thumb.jpg" width="146" height="119" /></a></p>
<p>Now, the question is:</p>
<p>&#160; Is this code valid or not?? </p>
<p>&#160; If valid, how? </p>
<p>&#160; If not valid, why? </p>
<p><strong>(Source: Eric Lippert&#8217;s Blog)</strong>&#160; </p>
</blockquote>
<p>So, I worked on that problem posted some comments there, and presenting it again here in the form of a post. </p>
<p>The moment I read the problem, things started running in my mind around </p>
<p><strong>var m in from m in data orderby m select m</strong> </p>
<p>as you can perceive, m is being used in two different contexts, first as a enumerator in LINQ query: &quot; from m in data orderby m select m &quot; </p>
<p>and the &quot;var m &quot; part in foreach. The question here: <strong>Can that possibly work?</strong> </p>
<p>Luckily, I was honing my skills in Reflection (System.Reflection) at that time, I get across a phrase in this book about foreach block (it says Cs compiler adds some temp. variable to smooth out operations like </p>
<blockquote><p>a += 2; </p>
<p>or </p>
<p>foreach(var m in M){}</p>
</blockquote>
<p>along with that there was also a prenotion that something &quot;magical&quot; happens when you encounter such situation, and whole code behaves like it is working in scopes (The blocks of { }). </p>
<p>So, the possible explanation, that came to my mind about this problem was : </p>
<p>the thing &quot;<strong>var m in from m in data orderby m select m</strong>&quot; </p>
<p>breaks up into two scopes : { var m } in { from m in data orderby m select m } </p>
<p>or in other terms var m in {from m in data orderby m select m} </p>
<p>We can proceed to further abstractions </p>
<p>var m = {from m&#8217; in data order by m&#8217; select m&#8217;} </p>
<p>that would eventually looks like </p>
<p>var m in m&#8217; // where m&#8217; is enumerable </p>
<p>[ <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' />  Oops, m' is not a valid name for a variable, but good for human beings] </p>
<p>&#160; </p>
<p>OK! I have a possible explanation, now how to confirm that its right and not a conjecture. </p>
<p>I fired <a href="http://www.rssbandit.org" target="_blank">RSS Bandit</a> and rushed to Eric Lippert&#8217;s blog&#8230; </p>
<blockquote><p>&lt;digression&gt; </p>
<p>x-( </p>
<p>Though I like reading blogs, but Internet, blogs and twitter (a.k.a Knowledge Supernova) provide so much information to absorb, I occasionally procrastinate reading RSS and let them aggregate scheduled to be read on weekends, after I am exhausted&#160; from celebrating TGIF and TGIS, so I missed the Eric Lipperts blog post that mentioned this problem <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  </p>
<p>&lt;/digression&gt; </p>
</blockquote>
<p>I fired <a href="http://www.rssbandit.org" target="_blank">RSS Bandit</a> and rushed to Eric Lippert&#8217;s blog and tried to find out where this problem is being discussed, and I failed to figure its occurrence since it was phrased at the end of blog post and I was flipping over top. </p>
<p>This made me more curious to find the real answer, so I fired VS, hit Ctrl + C, Ctrl+ V and some tabs, ran it and yes it was running fine, just like you would expect. </p>
<p><a href="http://thewiredguy.com/BlogImages/JustanotherwaytoanalysecodebehaviourInmy_F88/image.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/JustanotherwaytoanalysecodebehaviourInmy_F88/image_thumb.png" width="677" height="342" /></a></p>
<p>But, that doesn&#8217;t answer actually what concerns me: Is my explanation is completely right?</p>
<p>Suddenly, an idea struck me: Utilize Reflection</p>
<p>Advantage was that, it will cause extra practice much needed to get comfortable with reflection</p>
<p>So, I started writing code:</p>
<p>First, I wrote </p>
<pre class="csharpcode"><span class="kwrd">using</span> System.Linq;
<span class="kwrd">using</span> System.Reflection;
<span class="kwrd">using</span> System.Reflection.Emit;
<span class="kwrd">using</span> System.Collections.Generic;
    <span class="kwrd">class</span> Program
    {
      <span class="kwrd">static</span> <span class="kwrd">void</span> Main()
      {
         <span class="kwrd">int</span>[] data = { 1, 2, 3, 1, 2, 1 };
          <span class="kwrd">foreach</span> (var m <span class="kwrd">in</span> from m <span class="kwrd">in</span> data orderby m select m)
             System.Console.Write(m);
          <span class="kwrd">new</span> Analyse().Run();
          System.Console.ReadKey();
      }
    }
    <span class="kwrd">class</span> Analyse
    {
        <span class="kwrd">public</span> <span class="kwrd">void</span> Run()
        {
            Assembly asm = Assembly.GetAssembly(<span class="kwrd">typeof</span>(Program));
            MethodBody mb = asm.EntryPoint.GetMethodBody();
            System.Console.WriteLine(<span class="str">&quot;\nMethod Name: &quot;</span>+asm.EntryPoint.Name);
            <span class="kwrd">foreach</span> (var locals <span class="kwrd">in</span> mb.LocalVariables)
            {
                System.Console.WriteLine(<span class="str">&quot;\n {0}&quot;</span>, locals.LocalType.FullName);
            }
            System.Console.ReadKey();
        }
    }</pre>
<p>The Run method would actually list all the variables that are present after actual compilation, this will include the variables we have declared explicitly or implicitly as well as other variables introduced by compiler to store temporary results and perform calculations.</p>
<p>If you run it you will get output:</p>
<blockquote>
<p>&#160; </p>
<p>111223 </p>
<p>Method Name: Main </p>
<p>System.Int32[] </p>
<p>System.Int32 </p>
<p>System.Collections.Generic.IEnumerator`1[[System.Int32, mscorlib, Version=2.0.0.<br />
    <br />0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] </p>
<p>System.Boolean</p>
</blockquote>
<p>Ok! Let me set a context, before I go for explaining things here </p>
<p>change the body of main() method inside program class to</p>
<pre class="csharpcode"><span class="kwrd">using</span> System.Linq;
<span class="kwrd">using</span> System.Reflection;
<span class="kwrd">using</span> System.Reflection.Emit;
<span class="kwrd">using</span> System.Collections.Generic;
    <span class="kwrd">class</span> Program
    {
      <span class="kwrd">static</span> <span class="kwrd">void</span> Main()
      {
         <span class="kwrd">int</span>[] data = { 1, 2, 3, 1, 2, 1 };
          <span class="kwrd">foreach</span> (var num <span class="kwrd">in</span> data)
          {
              System.Console.Write(num);
          }
          <span class="kwrd">new</span> Analyse().Run();
          System.Console.ReadKey();
      }
    }
... contd.</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</p>
<p>How the output changes:</p>
<blockquote>
<p>123121 </p>
<p>Method Name: Main </p>
<p>System.Int32[] </p>
<p>System.Int32 </p>
<p>System.Int32[] </p>
<p>System.Int32 </p>
<p>System.Boolean</p>
</blockquote>
<p><u>A little explanation</u> </p>
<p>&#160; </p>
<blockquote>
<p>the first system.Int32[] is this array int[ ] data = { 1, 2, 3, 1, 2, 1 }; </p>
<p>next System.Int32 will receive value at each iteration and will be used in Write() [this is our var m] </p>
<p>the second System.Int32[] refers to ForEach&#8217;s copy of array. Remember foreach doesn&#8217;t allow changing contents, so it makes a copy. </p>
<p>the second Int32 is an index to track current iterator location </p>
<p>last is a boolean which stores the result of condition check</p>
</blockquote>
<p><strong></strong>&#160;</p>
<p><strong>Note</strong>: this is again guess work, but still quiet predictable <img alt=":P" src="http://www.kinnarshah.in/wp-includes/images/smilies/icon_razz.gif" /></p>
<p>Note that there are two occurrence of System.Int32, than how can I figure out, what is the purpose of the second one and last one</p>
<p>so, we again change the main() body to</p>
<p>&#160;</p>
<pre class="csharpcode"><span class="kwrd">static</span> <span class="kwrd">void</span> Main()
      {
         <span class="kwrd">char</span>[] ch = { <span class="str">'a'</span>, <span class="str">'b'</span>, <span class="str">'c'</span> };
         <span class="kwrd">foreach</span> (var num <span class="kwrd">in</span> ch)
         {
             System.Console.Write(num);
         }
          <span class="kwrd">new</span> Analyse().Run();
          System.Console.ReadKey();
      }
...
..</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>the output changes to :</p>
<blockquote>
<p>abc </p>
<p>Method Name: Main </p>
<p>System.Char[] </p>
<p>System.Char </p>
<p>System.Char[] </p>
<p>System.Int32 </p>
<p>System.Boolean</p>
</blockquote>
<p>so, you can see that, system.char (replacing first System.Int32) is getting the assigned value that will be Write() outputted, and thus by comparing the ordinal similarity between the two outputs, it would be right to think that first System.Int32 is receiving the current value of data (index to which, iteration is pointing). </p>
<p>Back to our actual code, analysing the output </p>
<blockquote>
<p>111223 </p>
<p>Method Name: Main </p>
<p>System.Int32[] </p>
<p>System.Int32 </p>
<p>System.Collections.Generic.IEnumerator`1[[System.Int32, mscorlib, Version=2.0.0.<br />
    <br />0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] </p>
<p>System.Boolean</p>
</blockquote>
<p>line by line, we can see that </p>
<p><em>System.Int32[ ]</em> </p>
<p>(the actual data[] array) </p>
<p><em>System.Int32<br />
    <br /></em>(that will receive value at each iteration and will be WriteLined/outputted) </p>
<p><em>System.Collections.Generic.IEnumerator`1[[System.Int32, mscorlib blah blah blah... ]]</em></p>
<p><em></em></p>
<p>( the generic IEnumerator generated from LINQ expression obtained, now all classes implementing IEnumerator has a method called MoveNext( ), hence it will not require any additional Sytem.int32 indexer, hence here it is absent in output)</p>
<p><em>System.Boolean<br />
    <br /></em>(condition check result as previously stated) </p>
<p>From all this, we get that compiler handle duplicate references smartly, until we play by his rules and work according to C# language specs <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>This technique forms (No, I didn&#8217;t discovered it) another tool to analyse the code behaviour. </p>
<p>As a side note, other such techniques you are familiar with are: </p>
<ul>
<li>looking at preprocessor output (those *.i files in C) </li>
<li>looking at post compile code </li>
<li>Looking at generated assembly code </li>
<li>running ILDASM x-( </li>
<li>debugging?? </li>
<li>blah blah blah (ask a real Expert, he will provide you an exhaustive list of such techniques) </li>
<p>  <u><strong></strong></u></ul>
<ul><strong><u>THE HAPPY ENDING</u></strong></p>
<blockquote>
<p>finally, on the other day when I was reading posts aggregated in RSS Bandit from coding horror, many other blogs and somewhere in middle Eric&#8217;s blog, I find this problem hiding at the bottom of the blog post, and by reading the blog post you can get the explanation and It seems that, I stand correct <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Still if you think, I am wrong somewhere, please comment here. I will be happy to get the right facts.</p>
</blockquote>
</ul>
<p><strong>Edit: </strong>I just found out that, Eric also posted next <a href="http://blogs.msdn.com/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx" target="_blank">post</a> in continuation to that problem, where he explains excellently the behaviour of this code, in his own way.</p>
<div id="flaresmith" class="feedflare"><script src="http://feeds.feedburner.com/~s/thewiredguy?i=http://www.thewiredguy.com/wordpress/?p=62" type="text/javascript" charset="utf-8"></script></div><img src="http://feeds.feedburner.com/~r/TheWiredGuy/~4/nKFCMF_XjlM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thewiredguy.com/wordpress/?feed=rss2&amp;p=62</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.thewiredguy.com/wordpress/?p=62</feedburner:origLink></item>
		<item>
		<title>Getting Started With Facebook App Development</title>
		<link>http://feedproxy.google.com/~r/TheWiredGuy/~3/e1I9XFUJeH4/</link>
		<comments>http://www.thewiredguy.com/wordpress/?p=60#comments</comments>
		<pubDate>Fri, 16 Oct 2009 19:25:11 +0000</pubDate>
		<dc:creator>Sanil</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Social Apps]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[facebook]]></category>
		<guid isPermaLink="false">http://sunny.byethost18.com/WP/?p=60</guid>
		<description><![CDATA[You all on facebook must have tried FB Quizzes and Apps. Nowadays, many are playing Mafia wars, Yoville and regularly going through funny and insane quizzes like &#8220;When will you die?&#8221; or in general playing &#8220;What? Why? When? Who?&#8221;.
In spite of being useless apps, multitude of people are rushing towards such apps&#8230;
don&#8217;t believe me! Have&#160; [...]]]></description>
			<content:encoded><![CDATA[<p align="justify"><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image.png"><img border="0" alt="image" align="right" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb.png" width="133" height="137"/></a>You all on facebook must have tried FB Quizzes and Apps. Nowadays, many are playing Mafia wars, Yoville and regularly going through funny and insane quizzes like &#8220;When will you die?&#8221; or in general playing &#8220;What? Why? When? Who?&#8221;.</p>
<p align="justify">In spite of being useless apps, multitude of people are rushing towards such apps&#8230;</p>
<p align="justify">don&#8217;t believe me! Have&nbsp; a look on stats of an application (A &#8220;who&#8221; quiz) that I launched,&nbsp; four days ago:</p>
<p align="justify">&nbsp;</p>
<p align="justify"><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_3.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" align="right" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_3.png" width="581" height="491"/></a></p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">&nbsp;</p>
<p align="justify">but, look writing these applications are pretty straight right, and further with <a href="http://blog.facebook.com/blog.php?post=2437282130" target="_blank">facebook platform API support</a>, it becomes a breeze, though it adds its own idiosyncrasies and difficulties. And with all that things comes an easy way to make money by showing ads, and other revenue models that&nbsp; can offer you considerable amount of money.</p>
<p align="justify"><strong><u></u></strong>&nbsp;</p>
<p align="justify"><strong><u><font size="5">Getting Started</font></u></strong></p>
<p align="justify"><strong><u><font size="5"></font></u></strong>&nbsp;</p>
<p align="justify"><strong><u>Add facebook developer application</u></strong></p>
<p align="justify">To start with, every developer who wants to develop facebook applications need to add &#8220;<a href="http://www.facebook.com/developers" target="_blank">facebook developer application</a>&#8220;. [ Here, I assume you already have a valid facebook user account ]</p>
<p><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_4.png"><img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_4.png" width="281" height="658"/></a> </p>
<p>&nbsp;</p>
<p><strong>A WebServer / web space running required middleware language</strong></p>
<p align="justify">Next you will need a web space (host) to host your application. A facebook application is basically a web application that communicates with facebook platform with its REST APIs.</p>
<p align="justify">These <a href="http://en.wikipedia.org/wiki/REST" target="_blank">REST</a> APIs functionality are available in the form of libraries for different platforms, that allows you to use facebook API without writing a lot of extra code. facebook has created there own <a href="http://wiki.developers.facebook.com/index.php/PHP" target="_blank">PHP client library</a>. </p>
<p align="justify">Other than that, there&nbsp; are plenty of <a href="http://wiki.developers.facebook.com/index.php/Client_Libraries" target="_blank">unofficial libraries</a> for supporting application development in your preferred language or framework.</p>
<p align="justify">I will be demonstrating here app development using the default PHP facebook API client library. </p>
<p align="justify"><strong>Facebook Application Architecture</strong></p>
<p align="justify"><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_5.png"><img border="0" alt="Facebook Application Architecture copyrigths Apress Publishers" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_5.png" width="410" height="524"/></a></p>
<p align="justify">Facebook provides your application to users when they request it through Facebook Application directory or follow some link pointing to your application. As you can see above, each time a Facebook user interacts with your application, It causes a series of server interactions with the Facebook server farm and your server. Each time a user requests something from your application&nbsp; through Facebook,&nbsp; that request is passed to your server to create the initial REST call to the Facebook API. Once your response to construct a display call (in FBML and HTML) and passes that back to the Facebook server. Facebook processes&nbsp; this information (the embedded FBML and JS) and creates an HTML response to the user. Because of the constant passing of information between servers,&nbsp; there&nbsp; is an additional level of complexity that can complicate tracking down bugs. You also need to consider this constant interaction when developing your application because you don’t want to make unnecessary API calls that will slow down your application.</p>
<p align="justify"><strong>Download Client-Library</strong></p>
<p align="justify">As discussed earlier, you can choose one from many available client libraries available for your favourite language. We will be using official facebook <a href="http://wiki.developers.facebook.com/index.php/PHP" target="_blank">PHP Client Library</a>, for other languages you can get one from <a href="http://wiki.developers.facebook.com/index.php/Client_Libraries" target="_blank">unofficial libraries</a>.</p>
<p align="justify">Once you’ve downloaded the library unzip it into a folder and upload to your webserver from where it is accessible by your PHP scripts. So you would have something like /php_include_directory/facebook/ and in that folder you will have the entire Facebook PHP Client Library (folders: client, footprints, php4client). I’m using PHP5 so my examples will be using the “client” directory of the library. The client library contains files and folders shown below:</p>
<p align="justify"><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_6.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_6.png" width="637" height="147"/></a></p>
<p align="justify">&nbsp;</p>
<p align="justify"><strong>Create Your Application Profile And API Key</strong></p>
<p align="justify">go <a href="http://www.facebook.com/developers/#" target="_blank">here</a>, and create an application profile</p>
<p align="justify"><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_7.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_7.png" width="786" height="658"/></a></p>
<p align="justify">&nbsp;</p>
<p align="justify"><strong>Choose a name for your application</strong>. This is important because it’s what users will see when they are browsing the application directory. Currently the name field is the only thing used when searching for applications. So it’s doubly important at this point.</p>
<p align="justify">&nbsp;</p>
<p><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_8.png"><img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://thewiredguy.com/BlogImages/GettingStartingWithF<br />
acebookAppDevelopmen_1C56/image_thumb_8.png" width="584" height="338"/></a></p>
<p>&nbsp;</p>
<p>Next fill out the <strong>Canvas Callback Url</strong> with the location of your script. This is the public URL on your webserver where the Facebook application will be, also <strong>fill out the “Canvas Page URL”</strong>. This is your application URL within Facebook. For example if the application was called “Play the DemoApp ” then the application URL could be: “DemoApp” which would make the full URL: <a href="http://apps.facebook.com/DemoApp/">http://apps.facebook.com/DemoApp/</a>.</p>
<p>&nbsp;</p>
<p><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_9.png"><img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_9.png" width="647" height="619"/></a></p>
<blockquote><p><strong>All of these settings can be changed anytime, even after the application has been created</strong>&nbsp;</p>
</blockquote>
<p>&nbsp;</p>
<p><strong>Get the API Key and Secret</strong></p>
<p><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_10.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_10.png" width="662" height="185"/></a> </p>
<p>You should never disclose the API Secret key (Hmm&#8230; Isn&#8217;t that what secret means?), the API key is used to uniquely identify your application and Secret is used for authentication purpose and during REST API calls.</p>
<p>&nbsp;</p>
<p>So far, we have selected a <a href="http://www.byethost.com" target="_blank">webserver</a> that supports your chosen middleware language (in our case PHP), now we can start writing our application.</p>
<p><strong>Select your IDE</strong></p>
<p>You can write your PHP applications on any suitable editor, even on notepad but that hearts a bit, so you can choose some common free or proprietary IDEs from <a href="http://en.wikipedia.org/wiki/List_of_integrated_development_environments_for_Python#PHP" target="_blank">here</a> on wikipedia, further in addition below is a list of some common IDEs:</p>
<ul>
<li>Crimson (<a href="http://www.crimsoneditor.com/)">http://www.crimsoneditor.com/)</a>&nbsp; [Windows]</li>
<li>ConTEXT (<a href="http://www.context.cx/)">http://www.context.cx/)</a>&nbsp; [Windows]</li>
<li>Dreamweaver (<a href="http://www.adobe.com/products/dreamweaver/)">http://www.adobe.com/products/dreamweaver/)</a>&nbsp; [Windows, OS X]</li>
<li>Eclipse PDT (<a href="http://www.eclipse.org/pdt/)">http://www.eclipse.org/pdt/)</a>&nbsp; [Windows, OS X, *nix]</li>
<li>EditPad Lite (<a href="http://www.editpadpro.com/editpadlite.html)">http://www.editpadpro.com/editpadlite.html)</a>&nbsp; [Windows]</li>
<li>Notepad++ (<a href="http://notepad-plus.sourceforge.net/uk/site.htm)">http://notepad-plus.sourceforge.net/uk/site.htm)</a>&nbsp; [Windows]</li>
<li>phpDesigner (<a href="http://www.mpsoftware.dk/)">http://www.mpsoftware.dk/)</a>&nbsp; [Windows]</li>
<li>PhpEd (<a href="http://www.nusphere.com/products/phped.htm)">http://www.nusphere.com/products/phped.htm)</a>&nbsp; [Windows]</li>
<li>PhpEdit (<a href="http://www.waterproof.fr/)">http://www.waterproof.fr/)</a>&nbsp; [Windows]</li>
<li>PHP Expert Editor (<a href="http://www.ankord.com/phpxedit.html)">http://www.ankord.com/phpxedit.html)</a>&nbsp; [Windows]</li>
<li>Quanta Plus (<a href="http://quanta.kdewebdev.org/)">http://quanta.kdewebdev.org/)</a>&nbsp; [*nix]</li>
<li>TextMate (<a href="http://macromates.com/)">http://macromates.com/)</a>&nbsp; [OS X]</li>
</ul>
<p>So, lets make our Demo App, what it will do:</p>
<ul>
<li>It will ask for user authorization to allow fetching user information via APIs</li>
<li>List some information about user</li>
</ul>
<pre class="csharpcode">    &lt;?php
        <span class="rem">// Name: index.php</span>
        <span class="rem">// My Demo App</span>
        <span class="rem">// facebook API library</span>
        require_once <span class="str">'../facebook-platform/php/facebook.php'</span>;
        <span class="rem">// The API key + secret</span>
        $api_key = <span class="str">"546dcaef3d4c5666c5eef65c4c15e196"</span>;
        $secret = <span class="str">"57secret57secret57secret57secret"</span>;
        <span class="rem">// Create the object containing API Client</span>
        $facebook = <span class="kwrd">new</span> Facebook($api_key, $secret);
        <span class="rem">// Shows standard "allow application" dialog, if user has not authorized</span>
        $user_id = $facebook-&gt;require_login();
    ?&gt;
    &lt;?php
        <span class="rem">// all API calls of form xxxx.function are called in the way xxxx_funtion in PHP API Client</span>
        <span class="rem">// call the users.getInfo facebook API</span>
        <span class="rem">// more details at http://wiki.developers.facebook.com/index.php/Users.getInfo</span>
        $userdetails = $facebook-&gt;api_client-&gt;users_getInfo($user_id,<span class="str">'name,pic,profile_url'</span>);
        echo <span class="str">"&lt;h2&gt; Demo App &lt;/h2&gt;"</span>;
        echo <span class="str">"&lt;img src='"</span>.$userdetails[0][<span class="str">'pic'</span>].<span class="str">"' /&gt;"</span>;
        echo <span class="str">"&lt;br /&gt;Name:"</span>.$userdetails[0][<span class="str">'name'</span>];
        echo <span class="str">"&lt;br /&gt;&lt;a href='"</span>.$userdetails[0][<span class="str">'profile_url'</span>].<span class="str">"' &gt;Go to profile&lt;/a&gt;"</span>;
    ?&gt;</pre>
<p><style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
</p>
<p>Save it as index.php and upload it under proper directory at your server, so that references to php client library are correct.Next, launch your browser, and type your application facebook application canvas url, it would be like: <a href="http://apps.facebook.com/&lt;app-name"><strong>http://apps.facebook.com/&lt;app-name</strong></a><strong>&gt;</strong>When you will run it, you will see the following screen:</p>
<p>&nbsp;</p>
<p><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_11.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_11.png" width="646" height="321"/></a></p>
<p>&nbsp;</p>
<p>This screen is a result of our following line of code</p>
<p>$user_id = $facebook-&gt;require_login(); </p>
<p>which causes facebook to show a standard prompt, through which our application gets permission to fetch user info from facebook profile datastore via API calls.</p>
<p>Click <strong>Allow </strong>to continue using app.</p>
<p>next we issue another API call:</p>
<p>$userdetails = $facebook-&gt;api_client-&gt;users_getInfo</p>
<p>This causes the REST API calls, and finally $userdetails contains the following value as an array:</p>
<p><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_12.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_12.png" width="590" height="172"/></a></p>
<p>&nbsp;</p>
<p>which&nbsp; we later print out using echo in out format:</p>
<p><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_13.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_13.png" width="379" height="198"/></a> </p>
<p>It is to be noted that all facebook applications run on the facebook page and thus are allowed a fixed space called application canvas, the blue box marks the facebook canvas in snapshot below:</p>
<p><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_14.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_14.png" width="640" height="334"/></a></p>
<p>(Click to enlarge)</p>
<p><strong>Where to go from here:</strong></p>
<p>What you have learned here are bare basics of FB App platform, for further information you can see following places:</p>
<p>You can start playing with APIs without any need of coding by going to <a href="http://developer.facebook.com/tools.php" target="_blank">developer tools</a>.</p>
<p><a href="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_15.png"><img border="0" alt="image" src="http://thewiredguy.com/BlogImages/GettingStartingWithFacebookAppDevelopmen_1C56/image_thumb_15.png" width="786" height="597"/></a></p>
<p>&nbsp;</p>
<p><u>Resources and Further Reading</u></p>
<ul>
<li><a href="http://developers.facebook.com/">Facebook Developers Site</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Main_Page">Facebook Developers Wiki</a></li>
<li><a href="http://www.sitepoint.com/article/developing-facebook-platform">Developing with the Facebook Platform and PHP</a></li>
<li><a title="Basic Facebook Application Architecture" href="http://wiki.developers.facebook.com/index.php/Random_questions#Basic_Application_Architecture">Basic Facebook Application Architecture</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Random_questions#URLS_in_my_application">How URLs Are Handled Within An Application</a>
</li>
<li><a href="http://wiki.developers.facebook.com/index.php/Your_callback_page_and_you">Understanding Your Callback Page</a></li>
</ul>
<p><u>Book</u>: Apress Facebook API Developers Guide (Mar 2008)</p>
<p><u>Forums</u>: <a title="Forums" href="http://forum.developers.facebook.com/">Facebook Forums</a></p>
<p>Hope you like this post providing some insight of facebook application development, please comment your views and post any queries freely.</p>
<p>Thanks for reading! <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div id="flaresmith" class="feedflare"><script src="http://feeds.feedburner.com/~s/thewiredguy?i=http://www.thewiredguy.com/wordpress/?p=60" type="text/javascript" charset="utf-8"></script></div><img src="http://feeds.feedburner.com/~r/TheWiredGuy/~4/e1I9XFUJeH4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thewiredguy.com/wordpress/?feed=rss2&amp;p=60</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.thewiredguy.com/wordpress/?p=60</feedburner:origLink></item>
		<item>
		<title>BlogEngine.NET: Pagination Extension</title>
		<link>http://feedproxy.google.com/~r/TheWiredGuy/~3/tAhZZqxtN0Y/</link>
		<comments>http://www.thewiredguy.com/wordpress/?p=59#comments</comments>
		<pubDate>Sat, 05 Sep 2009 01:42:46 +0000</pubDate>
		<dc:creator>Sanil</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">http://sunny.byethost18.com/WP/?p=59</guid>
		<description><![CDATA[This is the first release of Pagination, an extension&#160; for BlogEngine.NET
The aim of this extension is to make it simpler to navigate between different blog posts quickly.
It also have some little customisability by editing its CSS from extension manager to customize the look of the buttons. You can also [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first release of Pagination, an extension&nbsp; for BlogEngine.NET  </p>
<p>The aim of this extension is to make it simpler to navigate between different blog posts quickly.  </p>
<p><a href="http://thewiredguy.com/BlogImages/BlogEngine.NETPaginationExtension_66BE/Untitled.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 0px; border-right-width: 0px" height="298" alt="Untitled" src="http://thewiredguy.com/BlogImages/BlogEngine.NETPaginationExtension_66BE/Untitled_thumb.jpg" width="825" border="0"/></a>  </p>
<p>It also have some little customisability by editing its CSS from extension manager to customize the look of the buttons. You can also change the maximuum number of buttons from the extension manager.  </p>
<p>This has all been thrown together rather quickly so apologies for any problems you encounter.&nbsp; </p>
<p>Please send any feedback/bug reports to me and I will try and correct asap.  </p>
<p>Thanks.  </p>
<p>&nbsp; </p>
<p><a href="http://thewiredguy.com/downloads/Pagination.zip" target="_blank"><strong>Download [ Pagination.zip ]</strong></a></p>
<p><strong>Installation Instructions: </strong></p>
<p>Just unzip the compressed zip archive and copy/upload the Pagination.cs file to your BlogEngine.NET extension folder.</p>
<p><strong>Path relative to BlogEngine root</strong>:&nbsp; /AppCode/Extensions/</p>
<div id="flaresmith" class="feedflare"><script src="http://feeds.feedburner.com/~s/thewiredguy?i=http://www.thewiredguy.com/wordpress/?p=59" type="text/javascript" charset="utf-8"></script></div><img src="http://feeds.feedburner.com/~r/TheWiredGuy/~4/tAhZZqxtN0Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thewiredguy.com/wordpress/?feed=rss2&amp;p=59</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.thewiredguy.com/wordpress/?p=59</feedburner:origLink></item>
		<item>
		<title>Install Windows 7/Vista using a Pen Drive / USB Drive</title>
		<link>http://feedproxy.google.com/~r/TheWiredGuy/~3/rfTrz6Vh_As/</link>
		<comments>http://www.thewiredguy.com/wordpress/?p=56#comments</comments>
		<pubDate>Thu, 20 Aug 2009 22:27:24 +0000</pubDate>
		<dc:creator>Sanil</dc:creator>
				<category><![CDATA[Vista]]></category>
		<category><![CDATA[Windows Internals]]></category>
		<guid isPermaLink="false">http://sunny.byethost18.com/WP/?p=56</guid>
		<description><![CDATA[I used this method on one of my machines and installed the Windows 7 RC. The main advantage is that by using USB drive you will be able to install Windows 7/Vista in just 15 minutes. You can also use this bootable USB drive on friend’s computer who doesn’t have a DVD optical drive.  [...]]]></description>
			<content:encoded><![CDATA[<p>I used this method on one of my machines and installed the Windows 7 RC. The main advantage is that by using USB drive you will be able to install Windows 7/Vista in just 15 minutes. You can also use this bootable USB drive on friend’s computer who doesn’t have a DVD optical drive.  </p>
<p>The method is very simple and you can use without any hassles. Needless to say that your motherboard should support USB Boot feature to make use of the bootable USB drive.  </p>
<p><strong>1. Requirements</strong>
<ul>
<li>USB Flash Drive (&gt; 4GB)  </li>
<li>Windows 7 or Vista installation disk</li>
</ul>
<p><strong>2. Method</strong>  </p>
<p>Plug-in your USB flash drive to USB port and move all the contents from USB drive to a safe location on your system.  </p>
<p>Open Command Prompt with admin rights. Use any of the below methods to open Command Prompt with admin rights.  </p>
<p>*Type<strong> cmd</strong> in Start menu search box and hit<strong> Ctrl</strong>+ <strong>Shift</strong>+ <strong>Enter</strong>.  </p>
<p>Or  </p>
<p>*Go to Start menu &gt; All programs &gt; Accessories, right click on Command Prompt and select Run as administrator.  </p>
<p><strong>3</strong>. You need to know about the USB drive a little bit. Type in the following commands in the command prompt:  </p>
<p>First type <strong>DISKPART</strong> and hit enter to see the below message.  </p>
<p><a href="http://thewiredguy.com/BlogImages/InstallWindows7VistausingaPenDriveUSBDri_35AB/image.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="198" alt="image" src="http://thewiredguy.com/BlogImages/InstallWindows7VistausingaPenDriveUSBDri_35AB/image_thumb.png" width="676" border="0"/></a></p>
<p>&nbsp;</p>
<p>Next type <strong>LIST DISK</strong> command and note down the Disk number (ex: Disk 1) of your USB flash drive. In the below screenshot my Flash Drive Disk no is <strong>Disk 1</strong>. </p>
<p><a href="http://thewiredguy.com/BlogImages/InstallWindows7VistausingaPenDriveUSBDri_35AB/image_3.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="340" alt="image" src="http://thewiredguy.com/BlogImages/InstallWindows7VistausingaPenDriveUSBDri_35AB/image_thumb_3.png" width="677" border="0"/></a></p>
<p>Now proceed further on <strong>path1 </strong>or <strong>path2 </strong>as the condition may be true.</p>
<p><strong>Path 1: Here I assume that your disk drive no is “</strong><strong>Disk 1&#8243; and it is a pen drive with capacity &gt; 4 GB and no partition having your important data</strong> </p>
<p>&nbsp; </p>
<p>Type all the below commands one by one.  </p>
<p>Note: If you have Disk 2 as your USB flash drive then use Disk 2. </p>
<p>Refer the above step to confirm it. </p>
<p>So below are the commands you need to type and execute one by one: </p>
<p><strong>SELECT DISK 1 </strong> </p>
<p><strong>CLEAN</strong> </p>
<p><strong>CREATE PARTITION PRIMARY</strong> </p>
<p><strong>SELECT PARTITION 1</strong> </p>
<p><strong>ACTIVE</strong> </p>
<p><strong>FORMAT FS=NTFS</strong> </p>
<p>(Format process may take few seconds) </p>
<p><strong>ASSIGN</strong> </p>
<p><strong>EXIT</strong> </p>
<p><strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</strong> </p>
<p><strong><em>Path2: If you have a big USB Disk/ External Disk/ Portable hard disk, you can create a primary partition in it using disk manager and skip the CLEAN command, thus you don&#8217;t loose your data stored on other partition of same disk. Lets see how&#8230;</em></strong> </p>
<p><a href="http://thewiredguy.com/BlogImages/InstallWindows7VistausingaPenDriveUSBDri_35AB/image_4.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="168" alt="image" src="http://thewiredguy.com/BlogImages/InstallWindows7VistausingaPenDriveUSBDri_35AB/image_thumb_4.png" width="465" border="0"/></a></p>
<p>If you have a big USB disk, proceed by typing following command</p>
<p><strong>SELECT DISK 1 </strong> </p>
<p><strong>LIST PARTITION</strong> </p>
<p><strong>SELECT PARTITION 2 </strong> </p>
<p>Partition 2 is a 10 GB partition created for installation purpose. </p>
<p><a href="http://thewiredguy.com/BlogImages/InstallWindows7VistausingaPenDriveUSBDri_35AB/image_5.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="291" alt="image" src="http://thewiredguy.com/BlogImages/InstallWindows7VistausingaPenDriveUSBDri_35AB/image_thumb_5.png" width="516" border="0"/></a>  </p>
<p><strong>ACTIVE</strong>  </p>
<p><strong>FORMAT FS=NTFS</strong>  </p>
<p>(Format process may take few seconds)  </p>
<p><strong>ASSIGN</strong>  </p>
<p><strong>EXIT</strong></p>
<p>after going through path1 /path2, next insert your Windows7/Vista DVD into the optical drive and check the drive letter of the DVD drive. In this guide I will assume that your DVD drive letter is “D” and USB drive letter is “H” (open my computer to know about it). </p>
<p><strong>4</strong>. Maximize the minimized Command Prompt in the 4th step.Type&nbsp; the following command now: </p>
<p><strong>D:CD BOOT</strong> and hit enter.Where “D” is your DVD drive letter. </p>
<p><strong>CD BOOT</strong> and hit enter  </p>
<p><strong>5. </strong>Next, Copy your Windows 7/Vista DVD contents directly to the USB flash drive. </p>
<p><strong>6</strong>. Your USB drive is ready to boot and install Windows 7/Vista. Only thing you need to change the boot priority at the BIOS to USB from the HDD or CD ROM drive. I won’t explain it as it’s just the matter the changing the boot priority or enabling the USB boot option in the BIOS. </p>
<p>Note: If you are not able to boot after following this guide means you haven’t set the BIOS priority to USB. If you got any problem in following this guide feel free to ask questions by leaving comment. <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<div id="flaresmith" class="feedflare"><script src="http://feeds.feedburner.com/~s/thewiredguy?i=http://www.thewiredguy.com/wordpress/?p=56" type="text/javascript" charset="utf-8"></script></div><img src="http://feeds.feedburner.com/~r/TheWiredGuy/~4/rfTrz6Vh_As" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thewiredguy.com/wordpress/?feed=rss2&amp;p=56</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.thewiredguy.com/wordpress/?p=56</feedburner:origLink></item>
		<item>
		<title>TwitPic API Library : TwiPLi</title>
		<link>http://feedproxy.google.com/~r/TheWiredGuy/~3/0A33vlB7koU/</link>
		<comments>http://www.thewiredguy.com/wordpress/?p=53#comments</comments>
		<pubDate>Sun, 02 Aug 2009 18:39:35 +0000</pubDate>
		<dc:creator>Sanil</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[CodeProject]]></category>
		<guid isPermaLink="false">http://sunny.byethost18.com/WP/?p=53</guid>
		<description><![CDATA[On last weekend, I have been playing around with TwitPic API.
Ok! The thing is that TwitPic API is not that much complex, since all TwitPic provides is that it lets you post your funny/sad looking pictures or any picture you want to post on it, so it can be shared on twitter or any [...]]]></description>
			<content:encoded><![CDATA[<p><font size="2">On last weekend, I have been playing around with </font><a href="http://twitpic.com/api.do"><font size="2">TwitPic API</font></a><font size="2">. </font>
<p><font size="2">Ok! The thing is that </font><a href="http://twitpic.com/api.do"><font size="2">TwitPic API</font></a><font size="2"> is not that much complex, since all </font><a href="http://twitpic.com/"><font size="2">TwitPic</font></a><font size="2"> provides is that it lets you post your funny/sad looking pictures or any picture you want to post on it, so it can be shared on twitter or any other site. Its pretty much easy to implement all you have to know is how to create a web request, parse a XML, and post Multipart/form-data. You can get complete reference to TwitPic API here: </font><a href="http://twitpic.com/api.do"><font size="2">http://twitpic.com/api.do</font></a><font size="2"> </font>
<p><font size="2">Since, hosting pictures is a part of some web applications that, I write and will write in future. So, I wrote my own library in .NET framework, that I can use to post pictures on TwitPic. As usual being a lazy guy and considering that code and methods involved are straight forward. I’m giving link to the CodePlex hosted project page, where you can download the library and complete source code <strong>(MS-Pl Licensed).</strong> </font>
<p><font size="2">I have documented code at many places, wherever I thought was needed. So, there is very small possibility that you would say the “Holy F Word” while going through it, still if you may want to say so. <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  </font>
<p><a href="http://twipli.codeplex.com/"><font size="2"><strong>CodePlex Project Link</strong> http://twipli.codeplex.com</font></a><font size="2"> </font>
<p><font size="2">Here I would share the basic process, you need to follow to post your image file on TwitPic.com </font>
<p><font size="2">TwitPic.com provides 2 methods: UploadAndPost and Upload </font>
<p><font size="2">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; </font>
<p><font size="2"><strong>METHOD: </strong>UploadAndPost </font>
<p><b><font size="2">http://twitpic.com/api/uploadAndPost</font></b><a name="uploadAndPost"></a><font size="2"> </font>
<p><font size="2">Use this method to upload an image to TwitPic and to send it as a status update to Twitter. </font>
<p><font size="2">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; </font>
<p><font size="2"><strong>METHOD: </strong>Upload </font>
<p><b><font size="2">http://twitpic.com/api/upload</font></b><a name="upload"></a><font size="2"> </font>
<p><font size="2">Use this method if you just want to upload a photo to TwitPic. </font>
<p><font size="2">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; </font>
<p><font size="2">response to both method is in XML format. </font>
<p><font size="2">Here is an example: </font>
<p><font size="2"><strong>Fields to post in Method: UploadAndPost<br /></strong>(post data should be formatted as <strong>multipart/form-data</strong>): </font>
<p><font size="2">- media (required) &#8211; Binary image data<br />- username (required) &#8211; Twitter username<br />- password (required) &#8211; Twitter password<br />- message (optional) &#8211; Message to post to twitter. The URL of the image is automatically added.</font></p>
<p><font size="2">Response XML:</font></p>
<pre class="csharpcode"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">="1.0"</span> <span class="attr">encoding</span><span class="kwrd">="UTF-8"</span>?<span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">rsp</span> <span class="attr">status</span><span class="kwrd">="ok"</span><span class="kwrd">&gt;</span> <span class="kwrd">&lt;</span><span class="html">statusid</span><span class="kwrd">&gt;</span>1111<span class="kwrd">&lt;/</span><span class="html">statusid</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">userid</span><span class="kwrd">&gt;</span>11111<span class="kwrd">&lt;/</span><span class="html">userid</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">mediaid</span><span class="kwrd">&gt;</span>abc123<span class="kwrd">&lt;/</span><span class="html">mediaid</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">mediaurl</span><span class="kwrd">&gt;</span>http://twitpic.com/abc123<span class="kwrd">&lt;/</span><span class="html">mediaurl</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">rsp</span><span class="kwrd">&gt;</span>
</pre>
<p><font size="2"></font>&nbsp;</p>
<p><font size="2">Here is the abstract sequence in C# that is needed to do above:</font></p>
<p><font size="2">Let the variable<strong> Username</strong> and<strong> Password</strong> store the Twitter account credentials and <strong>ImagePath </strong>and <strong>Message </strong>are the path to image and Message to be posted.</font></p>
<p><font size="2">The first step would be to prepare the post data in Multipart/form-data format</font></p>
<pre class="csharpcode"><span class="kwrd">string</span> boundary = Guid.NewGuid().ToString();
<span class="kwrd">string</span> requestUrl = <span class="str">"http://twitpic.com/api/uploadAndPost"</span>;
<span class="kwrd">string</span> encoding = <span class="str">"iso-8859-1"</span>;
<span class="kwrd">string</span> header = <span class="kwrd">string</span>.Format(<span class="str">"--{0}"</span>, boundary);
<span class="kwrd">string</span> footer = <span class="kwrd">string</span>.Format(<span class="str">"--{0}--"</span>, boundary);
StringBuilder contents = <span class="kwrd">new</span> StringBuilder();
contents.AppendLine(header);
<span class="rem">//Add image to POST content string</span>
 <span class="rem">//determing file content-type                </span>
<span class="kwrd">string</span> fileContentType = GetFileContentType(filename); <span class="rem">//MIME type of image //The filename of image</span>
<span class="kwrd">string</span> fileHeader =
String.Format(<span class="str">"Content-Disposition: file; name=\"{0}\"; filename=\"{1}\""</span>, <span class="str">"media"</span>, filename);
<span class="kwrd">string</span> fileData = Encoding.GetEncoding(encoding).GetString(binaryImageData);
contents.AppendLine(fileHeader);
contents.AppendLine(String.Format(<span class="str">"Content-Type: {0}"</span>, fileContentType));
contents.AppendLine();
contents.AppendLine(fileData);
 <span class="rem">//Add user field in POST string                  </span>
contents.AppendLine(header);
contents.AppendLine(String.Format(<span class="str">"Content-Disposition: form-data; name=\"{0}\""</span>, <span class="str">"username"</span>));
contents.AppendLine();
contents.AppendLine(Username);
<span class="rem">//Add Password in POST string                 </span>
contents.AppendLine(header);
contents.AppendLine(String.Format(<span class="str">"Content-Disposition: form-data; name=\"{0}\""</span>, <span class="str">"password"</span>));
contents.AppendLine();
contents.AppendLine(Password);
 <span class="rem">//Add Message in Post string                </span>
<span class="kwrd">if</span> (!String.IsNullOrEmpty(Message))
{
                    contents.AppendLine(header);
                    contents.AppendLine(String.Format(<span class="str">"Content-Disposition: form-data; name=\"{0}\""</span>, <span class="str">"message"</span>));
                    contents.AppendLine();
                    contents.AppendLine(Message);
}
contents.AppendLine(footer);
encoding = <span class="str">"iso-8859-1"</span>;
<span class="kwrd">byte</span>[] bytes = Encoding.GetEncoding(encoding).GetBytes(contents.ToString());</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p><font size="2"></font>&nbsp;</p>
<p><font size="2">Here is the details of Method: <strong>GetFileContentType</strong></font></p>
<p>It simply returns appropriate MIME type, for an image format.</p>
<pre class="csharpcode"><span class="kwrd">private</span> <span class="kwrd">string</span> GetFileContentType(<span class="kwrd">string</span> FileName)
        {
            <span class="kwrd">if</span>(FileName.EndsWith(<span class="str">"jpg"</span>,<span class="kwrd">true</span>,System.Globalization.CultureInfo.CurrentCulture))
            {
                <span class="kwrd">return</span> <span class="str">"image/jpeg"</span>;
            }
            <span class="kwrd">else</span> <span class="kwrd">if</span>(FileName.EndsWith(<span class="str">"jpeg"</span>,<span class="kwrd">true</span>,System.Globalization.CultureInfo.CurrentCulture))
            {
                <span class="kwrd">return</span> <span class="str">"image/jpeg"</span>;
            }
            <span class="kwrd">else</span> <span class="kwrd">if</span>(FileName.EndsWith(<span class="str">"gif"</span>,<span class="kwrd">true</span>,System.Globalization.CultureInfo.CurrentCulture))
            {
                <span class="kwrd">return</span> <span class="str">"image/gif"</span>;
            }
            <span class="kwrd">else</span> <span class="kwrd">if</span>(FileName.EndsWith(<span class="str">"png"</span>,<span class="kwrd">true</span>,System.Globalization.CultureInfo.CurrentCulture))
            {
                <span class="kwrd">return</span> <span class="str">"image/png"</span>;
            }
            <span class="kwrd">else</span>
            {
                <span class="kwrd">return</span> <span class="str">""</span>;
            }
        }</pre>
<p><style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
</p>
<p>Finally parse the response XML, this is done by METHOD: RSPXMLParser</p>
<p>&nbsp;</p>
<pre class="csharpcode"><span class="kwrd">private</span> Response RSPXMLParser(<span class="kwrd">string</span> XMLresponse)
        {
            XmlDocument XmlDoc = <span class="kwrd">new</span> XmlDocument();
            <span class="kwrd">int</span>  UserId;
            <span class="kwrd">int</span> StatusId;
            <span class="kwrd">string</span> MediaId;
            <span class="kwrd">string</span> MediaUrl;
            <span class="kwrd">int</span> ErrorCode;
            <span class="kwrd">string</span> ErrorMessage;
            <span class="kwrd">try</span>
            {
                XmlDoc.LoadXml(XMLresponse);
                XmlNodeList RootNode = XmlDoc.SelectNodes(<span class="str">"rsp"</span>);
                <span class="kwrd">if</span>(RootNode.Item(0).Attributes[<span class="str">"status"</span>].InnerText==<span class="str">"ok"</span>)
                {
                    MediaId = RootNode.Item(0).SelectNodes(<span class="str">"mediaid"</span>).Item(0).InnerText;
                    MediaUrl = RootNode.Item(0).SelectNodes(<span class="str">"mediaurl"</span>).Item(0).InnerText;
                    <span class="kwrd">try</span>
                    {
                        UserId = <span class="kwrd">int</span>.Parse(RootNode.Item(0).SelectNodes(<span class="str">"userid"</span>).Item(0).InnerText);
                        StatusId = <span class="kwrd">int</span>.Parse(RootNode.Item(0).SelectNodes(<span class="str">"statusid"</span>).Item(0).InnerText);
                        <span class="kwrd">return</span> <span class="kwrd">new</span> Response(StatusId, UserId, MediaId, MediaUrl);
                    }
                    <span class="kwrd">catch</span>
                    {
                        <span class="kwrd">return</span> <span class="kwrd">new</span> Response(MediaId, MediaUrl);
                    }
                }
                <span class="kwrd">else</span>
                {
                    <span class="rem">//&lt;err code="1001" msg="Invalid twitter username or password" /&gt;</span>
                    ErrorCode = <span class="kwrd">int</span>.Parse(RootNode.Item(0).SelectNodes(<span class="str">"err"</span>).Item(0).Attributes[<span class="str">"code"</span>].InnerText);
                    ErrorMessage = RootNode.Item(0).SelectNodes(<span class="str">"err"</span>).Item(0).Attributes[<span class="str">"msg"</span>].InnerText;
                    <span class="kwrd">return</span> <span class="kwrd">new</span> Response(ErrorCode, ErrorMessage);
                }
            }
            <span class="kwrd">catch</span>(Exception ex)
            {
                <span class="kwrd">return</span> <span class="kwrd">new</span> Response(<span class="str">"XML Parse error: "</span>+ex.ToString());
            }
        }</pre>
<p><style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
</p>
<p><strong>The Response object referred above:</strong></p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> Response
    {
        <span class="kwrd">public</span> <span class="kwrd">readonly</span> <span class="kwrd">int</span> StatusID;                  <span class="rem">// like 1111</span>
        <span class="kwrd">public</span> <span class="kwrd">readonly</span> <span class="kwrd">int</span> UserID;                     <span class="rem">// like 11111</span>
        <span class="kwrd">public</span> <span class="kwrd">readonly</span> <span class="kwrd">string</span> MediaID;             <span class="rem">// like abc123</span>
        <span class="kwrd">public</span> <span class="kwrd">readonly</span> <span class="kwrd">string</span> MediaUrl;            <span class="rem">// Something like this http://twitpic.com/abc123</span>
        <span class="kwrd">public</span> <span class="kwrd">readonly</span> <span class="kwrd">string</span> MiniImage;         <span class="rem">// Mini Thumbnail URL</span>
        <span class="kwrd">public</span> <span class="kwrd">readonly</span> <span class="kwrd">string</span> ThumbImage;     <span class="rem">// Thumbnail URL</span>
        <span class="kwrd">public</span> <span class="kwrd">readonly</span> <span class="kwrd">bool</span> Status;                  <span class="rem">// True = Success | False= Fail <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </span>
        <span class="kwrd">public</span> <span class="kwrd">readonly</span> <span class="kwrd">int</span> ErrorCode;                 <span class="rem">// err_code= 1001 - Invalid twitter username or passwor</span>
                                                        <span class="rem">// err_code= 1002 - Image not found</span>
                                                        <span class="rem">// err_code= 1003 - Invalid image type</span>
                                                        <span class="rem">// err_code= 1004 - Image larger than 4MB </span>
        <span class="kwrd">public</span> <span class="kwrd">readonly</span> <span class="kwrd">string</span> ErrorMessage;     <span class="rem">//Will contain the sorry excuse for not doing ur job <img src='http://www.thewiredguy.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </span>
                                                         <span class="rem">//Invalid twitter username or password</span>
        <span class="kwrd">public</span> Response(<span class="kwrd">int</span> statusid, <span class="kwrd">int</span> userid, <span class="kwrd">string</span> mediaid, <span class="kwrd">string</span> mediaurl) <span class="rem">//to be called, when Method = UploadAndPost</span>
        {
                    StatusID = statusid;
                    UserID = userid;
                    MediaID = mediaid;
                    MediaUrl = mediaurl;
                    MiniImage = <span class="str">"http://twitpic.com/show/mini/"</span>+mediaid;
                    ThumbImage = <span class="str">"http://twitpic.com/show/thumb/"</span>+mediaid;;
                    Status = <span class="kwrd">true</span>;
                    ErrorCode = 0;
                    ErrorMessage = <span class="str">""</span>;
        }
        <span class="kwrd">public</span> Response(<span class="kwrd">string</span> mediaid, <span class="kwrd">string</span> mediaurl) <span class="rem">//to be called, when Method = Upload</span>
        {
            StatusID = 0;
            UserID = 0;
            MediaID = mediaid;
            MediaUrl = mediaurl;
            MiniImage = <span class="str">"http://twitpic.com/show/mini/"</span> + mediaid;
            ThumbImage = <span class="str">"http://twitpic.com/show/thumb/"</span> + mediaid; ;
            Status = <span class="kwrd">true</span>;
            ErrorCode = 0;
            ErrorMessage = <span class="str">""</span>;
        }
        <span class="kwrd">public</span> Response(<span class="kwrd">int</span> errorcode, <span class="kwrd">string</span> message) <span class="rem">//to be called, when error occurs</span>
        {
                    StatusID = -1;
                    UserID = -1;
                    MediaID = <span class="str">""</span>;
                    MediaUrl = <span class="str">""</span>;
                    MiniImage = <span class="str">""</span>;
                    ThumbImage = <span class="str">""</span>;
                    Status = <span class="kwrd">false</span>;
                    ErrorCode = errorcode;
                    ErrorMessage = message;
        }
        <span class="kwrd">public</span> Response(<span class="kwrd">string</span> message)
        {
            Status = <span class="kwrd">false</span>;
            ErrorCode = 0; <span class="rem">//there is some internal problem</span>
            ErrorMessage = message;
        }
    }</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>&nbsp;</p>
<p>You can run a quick demo of the <a href="http://twipli.codeplex.com" target="_blank">Library</a>, by creating an Instance in Object test bench and invoking the UploadAndPost method.</p>
<p>In case you want the source code, please download it from <a href="http://twipli.codeplex.com/" target="_blank">here</a></p>
<p><style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style></p>
<div id="flaresmith" class="feedflare"><script src="http://feeds.feedburner.com/~s/thewiredguy?i=http://www.thewiredguy.com/wordpress/?p=53" type="text/javascript" charset="utf-8"></script></div><img src="http://feeds.feedburner.com/~r/TheWiredGuy/~4/0A33vlB7koU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thewiredguy.com/wordpress/?feed=rss2&amp;p=53</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.thewiredguy.com/wordpress/?p=53</feedburner:origLink></item>
		<item>
		<title>TwitPic API Library : TwiPLi</title>
		<link>http://feedproxy.google.com/~r/TheWiredGuy/~3/bz9pwQSARNo/</link>
		<comments>http://www.thewiredguy.com/wordpress/?p=51#comments</comments>
		<pubDate>Sat, 01 Aug 2009 23:55:48 +0000</pubDate>
		<dc:creator>Sanil</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[CodeProject]]></category>
		<guid isPermaLink="false">http://sunny.byethost18.com/WP/?p=51</guid>
		<description><![CDATA[On last weekend, I have been playing around with TwitPic API.
Ok! The thing is that TwitPic API is not that much complex, since all TwitPic provides is that it lets you post your funny/sad looking pictures or any picture you want to post on it, so it can be shared on twitter or any other site.
�
Its [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0cm 0cm 0pt; text-align: justify; mso-pagination: none; mso-layout-grid-align: none; punctuation-wrap: simple;"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">On last weekend, I have been playing around with </span><a href="http://twitpic.com/api.do"><span style="font-size: 10pt; color: blue; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">TwitPic API</span></a><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">.</span></p>
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0cm 0cm 0pt; text-align: justify; mso-pagination: none; mso-layout-grid-align: none; punctuation-wrap: simple;"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US"></span></p>
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0cm 0cm 0pt; text-align: justify; mso-pagination: none; mso-layout-grid-align: none; punctuation-wrap: simple;"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">Ok! The thing is that </span><a href="http://twitpic.com/api.do"><span style="font-size: 10pt; color: blue; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">TwitPic API</span></a><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US"> is not<span style="mso-spacerun: yes;"> </span>that much complex, since all </span><a href="http://twitpic.com/"><span style="font-size: 10pt; color: blue; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">TwitPic</span></a><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US"> provides is that it lets you post your funny/sad looking pictures or any picture you want to post on it, so it can be shared on twitter or any other site.</span></p>
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0cm 0cm 0pt; text-align: justify; mso-pagination: none; mso-layout-grid-align: none; punctuation-wrap: simple;"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US"> </span></p>
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0cm 0cm 0pt; text-align: justify; mso-pagination: none; mso-layout-grid-align: none; punctuation-wrap: simple;"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">Its pretty much easy to implement all you have to know is how to create a web request, parse a XML, and post Multipart/form-data. </span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">You can get complete reference to TwitPic API here: </span><a href="http://twitpic.com/api.do"><span style="font-size: 10pt; color: blue; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">http://twitpic.com/api.do</span></a><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US"></span></p>
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0cm 0cm 0pt; text-align: justify; mso-pagination: none; mso-layout-grid-align: none; punctuation-wrap: simple;"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US"> </span></p>
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0cm 0cm 0pt; text-align: justify; mso-pagination: none; mso-layout-grid-align: none; punctuation-wrap: simple;"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">Since, hosting pictures is a part of some web applications that, I write and will write in future. So, I wrote my own library in .NET framework, that I can use to post pictures on TwitPic. </span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">As usual being a lazy guy and considering that code and methods involved are straight forward, I’m not providing the details here but, still I’m giving link to the CodePlex hosted project page, where you can download the library and complete source code (under MS-Pl License)</span></p>
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0cm 0cm 0pt; text-align: justify; mso-pagination: none; mso-layout-grid-align: none; punctuation-wrap: simple;"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US"> </span></p>
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0cm 0cm 0pt; text-align: justify; mso-pagination: none; mso-layout-grid-align: none; punctuation-wrap: simple;"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">I have documented code at many places, wherever I thought was needed. </span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">So, there is very small possibility that you would say the “Holy F Word” while going through it, still if you may want to say so.</span></p>
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0cm 0cm 0pt; text-align: justify; mso-pagination: none; mso-layout-grid-align: none; punctuation-wrap: simple;"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US"> </span></p>
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0cm 0cm 0pt; text-align: justify; mso-pagination: none; mso-layout-grid-align: none; punctuation-wrap: simple;"><a href="http://twipli.codeplex.com/"><span style="font-size: 10pt; color: black; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; text-decoration: none; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US; text-underline: none;" lang="EN-US">CodePlex Project Link</span><span style="font-size: 10pt; color: blue; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; text-decoration: none; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US; text-underline: none;" lang="EN-US"> </span><span style="font-size: 10pt; color: blue; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US">http://twipli.codeplex.com</span></a><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; mso-font-kerning: 14.0pt; mso-ansi-language: EN-US;" lang="EN-US"></span></p>
<div id="flaresmith" class="feedflare"><script src="http://feeds.feedburner.com/~s/thewiredguy?i=http://www.thewiredguy.com/wordpress/?p=51" type="text/javascript" charset="utf-8"></script></div><img src="http://feeds.feedburner.com/~r/TheWiredGuy/~4/bz9pwQSARNo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thewiredguy.com/wordpress/?feed=rss2&amp;p=51</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.thewiredguy.com/wordpress/?p=51</feedburner:origLink></item>
		<item>
		<title>Xinx Broadcast Chat</title>
		<link>http://feedproxy.google.com/~r/TheWiredGuy/~3/ETFzhQFBV8k/</link>
		<comments>http://www.thewiredguy.com/wordpress/?p=35#comments</comments>
		<pubDate>Sun, 14 Jun 2009 23:30:36 +0000</pubDate>
		<dc:creator>Sanil</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Code Project]]></category>
		<category><![CDATA[CodeProject]]></category>
		<guid isPermaLink="false">http://sunny.byethost18.com/WP/?p=35</guid>
		<description><![CDATA[Project Description Broadcast Chat is intended for chatting on LAN. It uses UDP broadcast for sending message across network. Its not just a dumb messenger, it allows many facilities like user presence detection, Asking questions etc.
&#160;
To know more about it, go to http://www.codeplex.com/XBC
Edit: Just released XBC V2.0
Features
Presence Detection
Presence Notification
Buzzing
Ask Yes/No Questions
Send Message Pop UP
Sits [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em><u>Project Description <br /></u></em></strong>Broadcast Chat is intended for chatting on LAN. <br />It uses UDP broadcast for sending message across network. <br />Its not just a dumb messenger, it allows many facilities like user presence detection, Asking questions etc. </p>
<p><strong><u></u></strong>&nbsp;</p>
<p>To know more about it, go to <a href="http://www.codeplex.com/XBC">http://www.codeplex.com/XBC</a></p>
<p><strong><u>Edit</u>:</strong> Just released XBC V2.0</p>
<p><strong><u>Features</u></strong></p>
<ul>
<li>Presence Detection
<li>Presence Notification
<li>Buzzing
<li>Ask Yes/No Questions
<li>Send Message Pop UP
<li>Sits in SysTray, and show notifications
<li>AutoComplete for some common messages </li>
</ul>
<p><img alt="Help.png" src="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=XBC&amp;DownloadId=59451" width="532" height="370"></p>
<div id="flaresmith" class="feedflare"><script src="http://feeds.feedburner.com/~s/thewiredguy?i=http://www.thewiredguy.com/wordpress/?p=35" type="text/javascript" charset="utf-8"></script></div><img src="http://feeds.feedburner.com/~r/TheWiredGuy/~4/ETFzhQFBV8k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thewiredguy.com/wordpress/?feed=rss2&amp;p=35</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.thewiredguy.com/wordpress/?p=35</feedburner:origLink></item>
	</channel>
</rss>
