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

<channel>
	<title>Martin Doms</title>
	<atom:link href="http://blog.martindoms.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.martindoms.com</link>
	<description>Musings on programming, photography and more</description>
	<lastBuildDate>Tue, 26 Jan 2010 05:08:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Salvaging a Bad Photograph in Photoshop</title>
		<link>http://blog.martindoms.com/2010/01/26/salvaging-a-bad-photo-in-photoshop/</link>
		<comments>http://blog.martindoms.com/2010/01/26/salvaging-a-bad-photo-in-photoshop/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 04:46:10 +0000</pubDate>
		<dc:creator>Martin Doms</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[photo editing]]></category>
		<category><![CDATA[photoshop]]></category>

		<guid isPermaLink="false">http://blog.martindoms.com/?p=260</guid>
		<description><![CDATA[I was at the Northern end of Lewis Pass when I came across the scene. What I saw was an ancient and proud late-spring mountain towering over the valley. She looked almost angry that any man would dare scar her age old nest with a callous and rude roadway. The brooding sky lay a dramatic [...]]]></description>
			<content:encoded><![CDATA[<p>I was at the Northern end of <a href="http://en.wikipedia.org/wiki/Lewis_Pass">Lewis Pass</a> when I came across the scene. What I saw was an ancient and proud late-spring mountain towering over the valley. She looked almost angry that any man would dare scar her age old nest with a callous and rude roadway. The brooding sky lay a dramatic drape over her.</p>
<p>What I captured on the sensor of my camera&#8230; well, I&#8217;ll let the image speak for itself.<br />
<div id="attachment_259" class="wp-caption alignnone" style="width: 778px"><img src="http://blog.martindoms.com/wp-content/uploads/2010/01/orig-light.jpg" alt="" title="Original Image" width="768" height="512" class="size-full wp-image-259" /><p class="wp-caption-text">Original Image</p></div><br />
<a href="http://blog.martindoms.com/wp-content/uploads/2010/01/orig-dark.jpg"><img src="http://blog.martindoms.com/wp-content/uploads/2010/01/orig-dark-300x200.jpg" alt="" title="orig-dark" width="300" height="200" class="alignright size-medium wp-image-258" /></a>Flat, uninspired and altogether disappointing. But the image I saw when I passed through stuck with me, and I decided it was time to have a crack at making my photograph reflect more accurately how I felt when I took it.</p>
<p>I&#8217;m going to start this with my perennial piece of advice &#8211; <strong>always shoot in RAW</strong>. I&#8217;m not going to go into detail about why this is because it has been discussed to death all over the internet. If you don&#8217;t know what RAW format is or don&#8217;t know why you should be using it, enroll yourself in Google University and find out &#8211; you&#8217;ll thank yourself for the results, trust me.</p>
<p>Now thankfully I had the presence of mind when shooting this scene to take two exposures. I could see that although my eye saw a dark and foreboding sky, that wasn&#8217;t going to be reflected in the final image due to the limited dynamic range of the camera&#8217;s sensor. So I shot one image to correctly expose the sky, and one image to correctly expose the road and mountains. This is not going to be an HDR image in the traditional sense, instead I am combining two separate images by manually blending them. On the right is the original image correctly exposed for the sky.</p>
<p>After doing the basic RAW conversion (very little was done in this step in this particular case so I won&#8217;t go into detail) I open both images in Photoshop. Don&#8217;t worry if you don&#8217;t have the latest and greatest CS4, all of the tools I&#8217;ll be using have been in PS for several years (except Smart Sharpen at the end, but you can substitute Unsharp Mask).<a href="http://blog.martindoms.com/wp-content/uploads/2010/01/layers1.png"><img src="http://blog.martindoms.com/wp-content/uploads/2010/01/layers1.png" alt="" title="layers1" width="242" height="141" class="alignleft size-full wp-image-267" /></a> I select the entire light image (Ctrl+A) and paste it on top of the dark image, so it&#8217;s on a new layer (see left).<a href="http://blog.martindoms.com/wp-content/uploads/2010/01/layers2.png"><img src="http://blog.martindoms.com/wp-content/uploads/2010/01/layers2.png" alt="" title="layers2" width="211" height="46" class="alignright size-full wp-image-268" /></a> I create a new Layer Mask for this new layer (see right). This mask allows me to use a brush to determine which parts of this layer are actually visible on top of the layer beneath.</p>
<p>I select the layer mask by clicking on the white box that appears next to the layer thumbnail and simply start drawing on the canvas with the Brush tool. I use a large brush with zero hardness to ensure that the edges of my mask can&#8217;t be easily picked out in the final image. Jobs like this are most easily done with a drawing tablet (I personally use a <a href="http://www.wacom.com/bamboo/bamboo_pen_touch.php">Wacom Bamboo</a>) but you can get by without one. In fact my tablet was not available for me to use when I made this image, so I did it all with just a mouse. After masking I have an image that looks like this:<br />
<img src="http://blog.martindoms.com/wp-content/uploads/2010/01/masked.jpg" alt="" title="Masked Up" width="768" height="512" class="alignnone size-full wp-image-270" /><br />
and with a mask that looks like this:<br />
<img src="http://blog.martindoms.com/wp-content/uploads/2010/01/mask.jpg" alt="" title="Mask" width="768" height="512" class="alignnone size-full wp-image-273" /></p>
<p>I want to pull a little more contrast out of the sky, so I inserted a new Levels Adjustment Layer in between the background and new layer (Layer -> New Adjustment Layer -> Levels&#8230;). The name of the game here is <i>non-destructive processing</i>. <img src="http://blog.martindoms.com/wp-content/uploads/2010/01/levels2.png" alt="" title="Levels" width="214" height="263" class="alignright size-full wp-image-276" />We try to do everything in layers, and this allows us to make changes to the final product without affecting the original image. An adjustment layer is a layer that makes certain adjustments to all visible layers beneath it. The advantage is that the adjustment layer can be hidden or deleted and the original images remain intact. I chose a Levels adjustment so that I could change the output white, mid and black levels with respect to the input levels, thereby increasing contrast and effectively &#8220;stretching&#8221; the dynamic range of the sky. On the right is my levels adjustment. </p>
<p>Here&#8217;s how the levels dialog works. That graph represents the brightness of the image &#8211; on the X axis are levels of brightness, from 0 to 255 (where 0 is black, 255 is white). The Y axis gives the number of pixels at that brightness level. So on the histogram on the right you can see we have a bunch of pixels at around 20-30 units of brightness, and another peak at around 170-190 units. The little sliders beneath the graph allow us to change the &#8220;black point&#8221; and &#8220;white point&#8221;. If we slide the left (black point) slider to the right then anything to the left of the slider becomes black, and similarly for white. Then the part of the histogram between the sliders is essentially stretched across the full 256 levels. The mid point does something similar with the middle of the histogram, and although it&#8217;s not as intuitively obvious how it will behave I encourage you to play with it to see how it affects contrast. Remember I&#8217;m using this layer just above the background so it will only affect the sky in this image.</p>
<p>My next step is to create a new layer at the top of this image. My goal here is to add more depth to the photograph and use lighting effects to draw the viewer in and also to try to give the scene that overbearing look that made me feel positively tiny when I was there. I use subtle light tricks to give the mountains a sense of scale that wasn&#8217;t present in the original image. I will use a special type of layer called an Overlay Layer. I click Layer->New Layer&#8230; and in the dialog box under Mode I select Overlay. This opens an option below the list box that says &#8220;Fill with Overlay-neutral color (50% gray)&#8221;. Tick this box. And overlay layer is a layer that affects the layers beneath it by changing the brightness of the lower layers depending on the brightness of the overlay layer. So areas where the overlay layer is brighter than 50% gray become brighter, and conversely for darker areas. This is why a 50% gray color is overlay-neutral, and why creating this layer has no effect on the final image at first.</p>
<p>We want to be relatively subtle with our effects on the overlay layer. A heavy hand here leads to an image that is so blatantly &#8220;Photoshopped&#8221; that that&#8217;s all people will see in your product. I use the dodge and burn tools (on the toolbar, hotkey O) with an exposure around 3-7% to change the overly layer. I have to be sure I&#8217;m actually working on the overlay and not on the image itself &#8211; remember, I&#8217;m working non-destructively here (and besides, the dodge and burn tools won&#8217;t give the look I&#8217;m after if applied to the image itself). Two useful hotkeys here are &#8216;[' and ']&#8216;, which change the size of your brush tools. Again, this job is much easier with a tablet but it&#8217;s not totally necessary.</p>
<p>I use dodge to make the image lighter in certain places &#8211; just above the road and on the portion of the mountain on the upper right third of the image. I burn other parts of the mountain to make them darker. By carefully choosing where to dodge and burn I can give the image a sense of depth and scale. It&#8217;s mostly a matter of experience and experimentation that gives the knowledge of where to dodge and burn. I never studied aesthetics so I can&#8217;t quantify what it is that makes an image look &#8220;deep&#8221;, I just know from doing it many, many times. If you need a concrete explanation of how to do this you&#8217;ll need to speak to some BA student in a black turtle-neck, because I fly this by the seat of my pants.</p>
<p>I want to add a couple of specific touches on this overlay layer as well. I burn the road heavily to give it a &#8220;black top&#8221; look, instead of the bright and washed out look it had in the original. I just think it looks cool. I also use a large burn brush to give the image a <a href="http://en.wikipedia.org/wiki/Vignetting">vignette</a>, an effect that is used to draw the viewer into an image in a kind of &#8220;tunnel vision&#8221; way. Please, be gentle with the vignette brush. A harsh vignette is highly distracting and in my opinion just looks silly. This image is about as far as I&#8217;d ever go with it. After all of these steps I&#8217;m left with this image<br />
<img src="http://blog.martindoms.com/wp-content/uploads/2010/01/overlay.jpg" alt="" title="After overlay" width="768" height="512" class="alignnone size-full wp-image-281" /><br />
and this overlay layer<br />
<img src="http://blog.martindoms.com/wp-content/uploads/2010/01/overlay2.jpg" alt="" title="Overlay" width="768" height="512" class="alignnone size-full wp-image-282" /></p>
<p>My final step is sharpening. Images pulled from RAW are generally quite soft. This is because a good RAW image has no processing done to it, and it&#8217;s a good thing. It means that we, the photographers, have full control over the sharpening step, rather than some mysterious algorithm designed by some software developer of indeterminate skill doing the work for us. I&#8217;m a big fan of the Photoshop Smart Sharpen (I think it has been around since CS3). I don&#8217;t usually even bother with the advanced settings as I find that changing just the Amount and Radius settings give me as fine a degree of control as I need in most cases. Filter -> Sharpen -> Smart Sharpen. For this image I used something like Amount = 150%, Radius = 1.4 pixels (I&#8217;m sorry, I can&#8217;t remember the exact settings but it&#8217;s around here). Experiment to find the settings that work for your picture. Generally if you have very fine, small details you&#8217;ll want to keep the radius very low (1 pixel or less in some cases), while having large details will allow you to bump the radius quite high, sometimes above 2.5 pixels.</p>
<p>Again I stress non-destructive editing, so before I apply any sharpening I hit Ctrl+Alt+Shift+E to create a new layer on top that is a merge of all visible layers below it. I then apply the sharpening to this new layer. Here&#8217;s another view of the original image, followed by the final product. I hope this article was helpful, and encourage you to leave a comment if you want to discuss things further.</p>
<p><img src="http://blog.martindoms.com/wp-content/uploads/2010/01/orig-light.jpg" alt="" title="orig-light" width="768" height="512" class="size-full wp-image-259" /></p>
<div id="attachment_286" class="wp-caption alignnone" style="width: 778px"><a href="http://www.flickr.com/photos/iamaelephant/4302197495/"><img src="http://blog.martindoms.com/wp-content/uploads/2010/01/finished.jpg" alt="Drama at Lewis Pass" title="Drama at Lewis Pass" width="768" height="512" class="size-full wp-image-286" /></a><p class="wp-caption-text">Drama at Lewis Pass</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.martindoms.com/2010/01/26/salvaging-a-bad-photo-in-photoshop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the Google Reader API – Part 3</title>
		<link>http://blog.martindoms.com/2010/01/20/using-the-google-reader-api-part-3/</link>
		<comments>http://blog.martindoms.com/2010/01/20/using-the-google-reader-api-part-3/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 22:07:09 +0000</pubDate>
		<dc:creator>Martin Doms</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[aggregation]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google reader]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://blog.martindoms.com/?p=184</guid>
		<description><![CDATA[Google Reader API series

Part 1 &#8211; Programming to the API
Part 2 &#8211; Listing API
Part 3 &#8211; Editing API
In part 3 of this series on using the Google Reader API I will discuss using the POST API to edit your Google Reader data. Although the REST architecture and HTTP in general doesn&#8217;t enforce it, Google appears [...]]]></description>
			<content:encoded><![CDATA[<p>Google Reader API series</p>
<ul>
<li><a href="http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/">Part 1 &#8211; Programming to the API</a></li>
<li><a href="http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/">Part 2 &#8211; Listing API</a></li>
<li>Part 3 &#8211; Editing API</ul>
<p>In part 3 of this series on using the Google Reader API I will discuss using the POST API to edit your Google Reader data. Although the <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST architecture</a> and HTTP in general doesn&#8217;t enforce it, Google appears to have chosen to make any commands which alter the state of your Reader account POST (as opposed to GET) requests.</p>
<p>In <a href="http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/">Part I</a> I went over how to program for the HTTP POST requests so for now I&#8217;ll just go over the API. Arguments to POST calls are stored in a separate message body, unlike GET arguments which are stored in the URL exclusively. This is the main differentiating factor between the two types of calls. All POST calls to the Google Reader API take a single GET argument in the URL string &#8211; the <i>client</i> argument, which is the same as the <i>client</i> argument seen in all of the API calls in <a href="http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/">Part II</a> of this series &#8211; just use a unique string identifying your own software package if in doubt.</p>
<p>For the purposes of this tutorial I&#8217;ll split the calls into a number of categories.</p>
<ul>
<li><strong><a href="#sub-editing">Subscription editing</a></strong> &#8211; adding, editing and removal of subscriptions and their folders/tags</li>
<li><strong><a href="#item-editing">Item editing</a></strong> &#8211; editing of items, such as adding/removing tags and stars, &#8220;liking&#8221; items, sharing (broadcasting) items, keeping items unread, etc.
<li><strong><a href="#email">Email</a></strong> &#8211; Emailing items using your Google Gmail account</ul>
<p><a name="sub-editing"></a><br />
<h2>Subscription Editing</h2>
<p><strong>URL:</strong> http://www.google.com/reader/api/0/subscription/edit?client=<i>[your client]</i><br />
<br />
<strong>POST Data</strong></p>
<table>
<tr>
<td width="75"  style="border-bottom:1px solid black"><strong>Argument</strong></td>
<td  style="border-bottom:1px solid black"><strong>Description</strong></td>
</tr>
<tr>
<td>s</td>
<td>The feed identifier. This is the URL of the feed preceeded by <i>feed/</i>, for example <font face="Courier New">feed/http://blog.martindoms.com/feed/</font> for this blog&#8217;s RSS feed.</p>
</td>
</tr>
<tr>
<td>ac</td>
<td>The action to take on this feed. Possible values are <font face="Courier New">subscribe</font> to subscribe, <font face="Courier New">unsubscribe</font> to unsubscribe and <font face="Courier New">edit</font> to edit the feed.</p>
</td>
</tr>
<tr>
<td>t</td>
<td>The title to give the feed, only relevant in <font face="Courier New">subscribe</font> and <font face="Courier New">edit</font> actions.</p>
</td>
</tr>
<tr>
<td>r</td>
<td>A label to remove from the feed. This is in the format <font face="Courier New">user/<i>[UserID]</i>/label/<i>[LabelName]</i></font>. As usual <i>UserID</i> can be replaced with a single dash. For example, to remove the label &#8220;MyLabel&#8221; you&#8217;d use the string <font face="Courier New">user/-/label/MyLabel</font></p>
</td>
</tr>
<tr>
<td>a</td>
<td>A label to add to the feed. See the notes for the <i>r</i> argument above.</p>
</td>
</tr>
<tr>
<td>T</td>
<td>Your token (see <a href="http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/">Part I</a> if you&#8217;re unsure of what this is). This is an argument in every POST call.</p>
</td>
</tr>
</table>
<p></p>
<h4>Examples</h4>
<p><strong>Adding a feed</strong> &#8211; let&#8217;s add this blog&#8217;s main RSS feed to our subscriptions, but give it the title &#8220;Mr Doms&#8217; Blog&#8221;. We&#8217;ll POST the following data to the relevant URL (at the <a href="#sub-editing">top</a> of this section). You&#8217;ll need to URL encode this data before posting but I&#8217;ve left it unencoded for ease of reading. Let&#8217;s assume I&#8217;ve already got myself a token which looks like <i>abcde.ABCD1234abc</i><br />
<font face="Courier New">s=feedhttp://blog.martindoms.com/feed/&#038;ac=subscribe&#038;t=Mr Doms&#8217; Blog&#038;T=abcde.ABCD1234abc</font><br />
<strong>Editing a feed</strong> &#8211; we want to add this feed to our &#8220;Infrequently Updated Blogs&#8221; folder on Google Reader to keep things organized. POST this data:<br />
<font face="Courier New">a=user/-/label/Infrequently Updated Blogs&#038;s=feed/http://blog.martindoms.com/feed/&#038;ac=edit&#038;<br />
T=abcde.ABCD1234abc</font><br />
<strong>Removing a feed</strong> &#8211; finally, let&#8217;s remove this blog from our subscriptions out of frustration at Martin&#8217;s lack of regular updates.<br />
<font face="Courier New">s=feed/http://blog.martindoms.com/feed/&#038;ac=unsubscribeT=abcde.ABCD1234abc</font></p>
<p><a name="item-editing"></a><br />
<h2>Item Editing</h2>
<p><strong>URL:</strong> http://www.google.com/reader/api/0/edit-tag?client=<i>[your client]</i><br />
<br />
<strong>POST Data</strong></p>
<table>
<tr>
<td width="75"  style="border-bottom:1px solid black"><strong>Argument</strong></td>
<td  style="border-bottom:1px solid black"><strong>Description</strong></td>
</tr>
<tr>
<td>a</td>
<td>A new tag to add. This can take one of several formats depending on the type of tag you&#8217;re adding to the item. See the notes at the bottom of this table for details.</td>
</tr>
<tr>
<td>r</td>
<td>Remove an existing tag. This tag can take one of several formats depending on the type of tag you&#8217;re removing from the item. See the notes at the bottom of this table for details.</td>
</tr>
<tr>
<td>async</td>
<td>Can be either true or false. This appears to be a utility argument for Google&#8217;s own website, as it doesn&#8217;t seem to make a difference to my API calls.</td>
</tr>
<tr>
<td>s</td>
<td>The feed that this item belongs to. See the previous section for information on the format of this argument.</td>
</tr>
<tr>
<td>i</td>
<td>The item you want to tag. This is in the format <font face="Courier New">tag:google.com,2005:reader/item/[item identifier]</font>.</td>
</tr>
<tr>
<td>T</td>
<td>As usual this is your token. See <a href="http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/">Part I</a> if you&#8217;re unsure about what this is.</td>
</tr>
</table>
<p><strong>Tag identifier formatting</strong> &#8211; to add or remove a tag on an item you need to use a tag identifier string in the <i>a</i> or <i>r</i> argument. Google doesn&#8217;t seem to have a fully consistent way of formatting these tag identifiers, but here&#8217;s what I&#8217;ve figured out.</p>
<ul>
<li>Add/remove a custom tag (item label): <font face="Courier New">user/-/label/[NewTag]</font></li>
<li>Mark an item read or unread: <font face="Courier New">user/-/com.google/read</font></li>
<li>Star an item: <font face="Courier New">user/-/state/com.google/starred</font></li>
<li>Add or remove a &#8220;keep unread&#8221; tag: <font face="Courier New">user/-/state/com.google/tracking-kept-unread</font></li>
<li>&#8220;Like&#8221; or un-&#8221;like&#8221; an item: <font face="Courier New">user/-/state/com.google/like</font></li>
<li>Share or unshare an item with Google Reader friends: <font face="Courier New">user/-/state/com.google/broadcast</font></li>
</ul>
<h4>Examples</h4>
<p>To use any tag features you&#8217;ll need to retrieve an item identifier. Presumably if you&#8217;re displaying items in your software then you&#8217;ve already got an item identifier. If you don&#8217;t know how to retrieve these items, see <a href="http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/">Part II</a> for the listing API. For the purpose of these examples I&#8217;ll be working with an item that represents Part I of this series, which happens to be item <font face="Courier New">0816b6dbac1d768d</font>. We&#8217;ll also be assuming a token string abcde.ABCD1234abc as before.<br />
<strong>Add a star</strong> &#8211; to add a star we send the POST data <font face="Courier New">a=user/-/state/com.google/starred&#038;async=true&#038;s=feed/http://blog.martindoms.com/feed/&#038;i=tag:google.com,2005:reader/item/0816b6dbac1d768d&#038;T=abcde.ABCD1234abc</font><br />
<strong>Mark as unread</strong> &#8211; we want to remove the &#8220;read&#8221; tag to mark an item as unread. Use this POST data: <font face="Courier New">a=user/-/state/com.google/read&#038;async=true&#038;s=feed/http://blog.martindoms.com/feed/&#038;i=tag:google.com,2005:reader/item/0816b6dbac1d768d&#038;T=abcde.ABCD1234abc</font><br />
<br />The item tagging doesn&#8217;t get any more complicated than that. Easy!</p>
<p><a name="email"></a><br />
<h2>Emailing</h2>
<p><strong>URL:</strong> http://www.google.com/reader/email-this?ck=<i>[CurrentUnixTime]</i>&#038;client=<i>[YourClient]</i><br />
(current Unix time argument is optional)<br />
<br />
<strong>POST Data</strong></p>
<table>
<tr>
<td width="75"  style="border-bottom:1px solid black"><strong>Argument</strong></td>
<td  style="border-bottom:1px solid black"><strong>Description</strong></td>
</tr>
<tr>
<td>i</td>
<td>The item identifier. See the <a href="#item-editing">previous section</a> for details.</td>
</tr>
<tr>
<td>emailTo</td>
<td>The email addresses to send the item to. You can send to multiple recipients. These addresses are in the format <font face="Courier New">
<person1@internet.com>,
<person2@isp.net>, </font></td>
</tr>
<tr>
<td>comment</td>
<td>The email body</td>
</tr>
<tr>
<td>subject</td>
<td>The email subject</td>
</tr>
<tr>
<td>ccMe</td>
<td>Whether to send the email to your own GMail account also. Can be true or false.</td>
</tr>
<td>T</td>
<td>Your token. See <a href="http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/">Part I</a> if you&#8217;re unsure of what this is.</td>
</tr>
</table>
<h4>Example</h4>
<p>Here&#8217;s some example POST data to send an email about Part I of this series of articles to the address example@example.com<br />
<font face="Courier New">i=i=tag:google.com,2005:reader/item/0816b6dbac1d768&#038;emailTo= &lt;example@example.com&gt;, &#038;comment=Check this out&#038;subject=Google Reader API&#038;ccMe=false&#038;T=abcde.ABCD1234abc</font></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.martindoms.com/2010/01/20/using-the-google-reader-api-part-3/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using the Google Reader API &#8211; Part 2</title>
		<link>http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/</link>
		<comments>http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 03:06:14 +0000</pubDate>
		<dc:creator>Martin Doms</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[aggregation]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google reader]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://blog.martindoms.com/?p=116</guid>
		<description><![CDATA[Google Reader API series

Part 1 &#8211; Programming to the API
Part 2 &#8211; Listing API
Part 3 &#8211; Editing API
In this post I will discuss the listing API for Google reader. This encapsulates all of the calls you&#8217;ll need to list items and feeds in various ways. The table below summarizes the API URLs you&#8217;ll be using. [...]]]></description>
			<content:encoded><![CDATA[<p>Google Reader API series</p>
<ul>
<li><a href="http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/">Part 1 &#8211; Programming to the API</a></li>
<li>Part 2 &#8211; Listing API</li>
<li><a href="http://blog.martindoms.com/2010/01/20/using-the-google-reader-api-%e2%80%93-part-3/">Part 3 &#8211; Editing API</a></ul>
<p>In this post I will discuss the listing API for Google reader. This encapsulates all of the calls you&#8217;ll need to list items and feeds in various ways. The table below summarizes the API URLs you&#8217;ll be using. Simply follow the table from left to right to find your target API handle. Click on a terminal item to see a summary of what it does and how to use it.</p>
<p>Note that for the <i>user</i> items I have found that substituting a dash for the user number works in every case I&#8217;ve tested, because a user needs to be logged in with a valid token to use these calls anyway.</p>
<p>If this is your first foray into using the Google Reader API then you&#8217;ll want to read <a href="http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/">my previous post</a> which describes how to acquire a valid token and cookie, and make calls to the API. Unlike part 1 of this series, this part is totally language agnostic.</p>
<h3>URL structure: http://www.google.com/&#8230;</h3>
<p></p>
<table style="font-family:Courier;border:0" border="1">
<tbody>
<tr>
<td rowspan="15">/reader/api/0/</td>
</tr>
<tr>
<td><a href="#unread-count">unread-count</a></td>
</tr>
<tr>
<td><a href="#user-info">user-info</a></td>
</tr>
<tr>
<td rowspan="15">stream/contents/</td>
</tr>
<tr>
<td><a href="#feed">feed/[feedurl]</a></td>
</tr>
<tr>
<td rowspan="8">user/[userNumber]/</td>
</tr>
<tr>
<td><a href="#labelname">label/[labelName]</a></td>
</tr>
<tr>
<td rowspan="8">state/com.google/</td>
</tr>
<tr>
<td><a href="#readinglist">reading-list</a></td>
</tr>
<tr>
<td><a href="#starred">starred</a></td>
</tr>
<tr>
<td><a href="#broadcast">broadcast</a></td>
</tr>
<tr>
<td><a href="#created">created</a></td>
</tr>
</tbody>
</table>
<p><a name="unread-count"></a><br />
<h2>unread-count</h2>
<p>Gets a list of feeds for the current user and the number of unread items in each feed. Also returns a list of labels that the user has created.<br />
<strong>Parameters</strong></p>
<ul>
<li>allcomments=<i>[true|false]</i> : I&#8217;m not sure what this parameter does, please leave a comment if you figure this one out.</li>
<li>output=<i>[json|xml]</i> : Determines the format of the response. Default: xml</li>
<li>ck=<i>[unix timestamp]</i> : Use the current Unix time here, helps Google with caching</li>
<li>client=<i>[your client]</i> : You can use the default Google client (scroll), but it doesn&#8217;t seem to make a difference. Google probably uses this field to gather data on who is accessing the API, so I&#8217;d advise using your own unique string to identify your software.</li>
</ul>
<p><strong>Sample Output (XML)</strong></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">GET http://www.google.com/reader/api/0/unread-count?allcomments=true&amp;output=xml&amp;ck=1255643091105&amp;client=scroll</div></div>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;number</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;max&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>1000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;unreadcounts&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;id&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>feed/http://www.pwop.com/feed.aspx?show=dotnetrocks<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;number</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;count&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;number</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;newestItemTimestampUsec&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>1255568508813466<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;id&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>feed/http://rssnewsapps.ziffdavis.com/audioblogs/crankygeeks/cg.audio.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;number</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;count&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;number</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;newestItemTimestampUsec&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>1255578279704094<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;id&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>user/01723985652832499840/label/myLabel<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;number</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;count&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>4<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;number</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;newestItemTimestampUsec&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> 1256030778673945 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p><strong>Sample Output (JSON)</strong></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">GET http://www.google.com/reader/api/0/unread-count?allcomments=false&amp;output=json&amp;ck=1255643091105&amp;client=myApplication</div></div>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">{<br />
&quot;max&quot;:1000,<br />
&quot;unreadcounts&quot;:<br />
&nbsp; &nbsp; [<br />
&nbsp; &nbsp; {&quot;id&quot;:&quot;feed/http://www.pwop.com/feed.aspx?showu003ddotnetrocks&quot;,&quot;count&quot;:3,&quot;newestItemTimestampUsec&quot;:&quot;1255568508813466&quot;},<br />
&nbsp; &nbsp; {&quot;id&quot;:&quot;feed/http://rssnewsapps.ziffdavis.com/audioblogs/crankygeeks/cg.audio.xml&quot;,&quot;count&quot;:1,&quot;newestItemTimestampUsec&quot;:&quot;1255578279704094&quot;},<br />
&nbsp; &nbsp; {&quot;id&quot;:&quot;user/01723985652832499840/label/myLabel&quot;,&quot;count&quot;:4,&quot;newestItemTimestampUsec&quot;:&quot;1256030778673945&quot;}<br />
&nbsp; &nbsp; ]<br />
}</div></div>
<p><a name="user-info"></a><br />
<h2>user-info</h2>
<p>Gets information on the current user<br />
<strong>Parameters</strong></p>
<ul>
<li>ck=<i>[unix timestamp]</i> : Use the current Unix time here, helps Google with caching</li>
<li>client=<i>[your client]</i> : You can use the default Google client (scroll), but it doesn&#8217;t seem to make a difference. Google probably uses this field to gather data on who is accessing the API, so I&#8217;d advise using your own unique string to identify your software.</li>
</ul>
<p></code><br />
<strong>Sample Output</strong></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">GET http://www.google.com/reader/api/0/user-info?&amp;ck=1255643091105&amp;client=myApplication</div></div>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">{<br />
&nbsp; &nbsp; &quot;userId&quot;:&quot;01723985652832499840&quot;,<br />
&nbsp; &nbsp; &quot;userName&quot;:&quot;username&quot;,<br />
&nbsp; &nbsp; &quot;userProfileId&quot;:&quot;123456789123456789123&quot;,<br />
&nbsp; &nbsp; &quot;userEmail&quot;:&quot;username@gmail.com&quot;,<br />
&nbsp; &nbsp; &quot;isBloggerUser&quot;:true,<br />
&nbsp; &nbsp; &quot;signupTimeSec&quot;:1234515320<br />
}</div></div>
<p><a name="feed"></a><br />
<h2>feed/[feedurl]</h2>
<p>Gets items belonging to a particular feed.<br />
<strong>Parameters</strong></p>
<ul>
<li>ot=<i>[unix timestamp]</i> : The time from which you want to retrieve items. Only items that have been crawled by Google Reader after this time will be returned.</li>
<li>r=<i>[d|n|o]</i> : Sort order of item results. <i>d</i> or <i>n</i> gives items in descending date order, <i>o</i> in ascending order.</li>
<li>xt=<i>[exclude target]</i> : Used to exclude certain items from the feed. For example, using xt=user/-/state/com.google/read will exclude items that the current user has marked as read, or xt=feed/[feedurl] will exclude items from a particular feed (obviously not useful in this request, but xt appears in other listing requests).</li>
<li>n=<i>[integer]</i> : The maximum number of results to return.</li>
<li>ck=<i>[unix timestamp]</i> : Use the current Unix time here, helps Google with caching.</li>
<li>client=<i>[your client]</i> : You can use the default Google client (scroll), but it doesn't seem to make a difference. Google probably uses this field to gather data on who is accessing the API, so I'd advise using your own unique string to identify your software.</li>
</ul>
<p></code><br />
<strong>Sample Output</strong></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">GET http://www.google.com/reader/api/0/stream/contents/feed/http://astronomycast.com/podcast.xml?ot=1253052000&amp;r=n&amp;xt=user/-/state/com.google/read&amp;n=20&amp;ck=1255646178892&amp;client=myApplication</div></div>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">{<br />
&nbsp; &nbsp; &quot;id&quot;:&quot;feed/http://astronomycast.com/podcast.xml&quot;,<br />
&nbsp; &nbsp; &quot;title&quot;:&quot;Astronomy Cast&quot;,<br />
&nbsp; &nbsp; &quot;continuation&quot;:&quot;CLbwxoSAsZsC&quot;,<br />
&nbsp; &nbsp; &quot;self&quot;:[{&quot;href&quot;:&quot;http://www.google.com/reader/api/0/stream/contents/feed/http://astronomycast.com/podcast.xml?&quot;}],<br />
&nbsp; &nbsp; &quot;alternate&quot;:[{&quot;href&quot;:&quot;http://www.astronomycast.com&quot;,&quot;type&quot;:&quot;text/html&quot;}],<br />
&nbsp; &nbsp; &quot;updated&quot;:1255415774,<br />
&nbsp; &nbsp; &quot;items&quot;:[<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;crawlTimeMsec&quot;:&quot;1255415774867&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;id&quot;:&quot;tag:google.com,2005:reader/item/bfbd19b1936fcccf&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;categories&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; [<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;user/01723985652832499840/state/com.google/reading-list&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;user/01723985652832499840/state/com.google/fresh&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;title&quot;:&quot;Ep. 156: Famous Stars&quot;,&quot;published&quot;:1253491200,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;updated&quot;:1253491200,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;enclosure&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; [<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;href&quot;:&quot;http://feedproxy.google.com/~r/astronomycast/~5/4TPW83-0h4Y/AstroCast-090921.mp3&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;type&quot;:&quot;audio/mpeg&quot;,&quot;length&quot;:&quot;17610000&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; ],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;alternate&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; [<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;href&quot;:&quot;http://feedproxy.google.com/~r/astronomycast/~3/89_Ck5HN--w/&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;type&quot;:&quot;text/html&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; ],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;mediaGroup&quot;:{&quot;content&quot;:[{&quot;url&quot;:&quot;http://feedproxy.google.com/~r/astronomycast/~5/4TPW83-0h4Y/AstroCast-090921.mp3&quot;}]},<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;summary&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;direction&quot;:&quot;ltr&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;content&quot;:&quot;This week we're going to talk about famous stars. But not those boring ...&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; },<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;author&quot;:&quot;info@astronomycast.com (Fraser Cain \u0026 Dr. Pamela Gay)&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;likingUsers&quot;:[],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;comments&quot;:[],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;annotations&quot;:[],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;origin&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;streamId&quot;:&quot;feed/http://astronomycast.com/podcast.xml&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;title&quot;:&quot;Astronomy Cast&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;htmlUrl&quot;:&quot;http://www.astronomycast.com&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; },<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;crawlTimeMsec&quot;:&quot;1255415774867&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;id&quot;:&quot;tag:google.com,2005:reader/item/008d8a870f2a9dee&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; }]<br />
}</div></div>
<p><strong>Output summary</strong><br />
This request returns an object that contains:</p>
<ul>
<li>Feed id string</li>
<li>Feed title string</li>
<li>Continuation string<i> - what is this? Leave a comment if you know</i></li>
<li>Self - an array of objects which contain a link to this list</li>
<li>Alternate - an array of objects which contain non-Google links to the feed (usually the author's RSS)</li>
<li>Updated timestamp</li>
<li>Items - an array of item objects which contain
<ul>
<li>Crawl time - when the item was crawled by Google Reader</li>
<li>Id - a unique identifier for the item</li>
<li>Categories - an array of categories to which this item belongs. These appear to be user-specific</li>
<li>Item title string</li>
<li>Updated timestamp</li>
<li>Enclosure - an array of enclosure objects. These are used mostly for podcasts/videocasts, they contain media items enclosed in the feed item. Enclosure items are composed of
<ul>
<li>A link to the media file</li>
<li>An <a href="http://en.wikipedia.org/wiki/Internet_media_type">internet media type</a></li>
<li>Length, in bytes</li>
</ul>
<li>An array of alternate links to the item</li>
<li>Media Group - appears to be an object storing an array of direct links to the enclosure media</li>
<li>Summary - an object containing a description of the feed item and a direction (ltr or rtl) for reading. <i>Is this direction a byte ordering hack? Someone let me know in the comments.</i></li>
<li>Author string</li>
<li>An array of users who "like" the item</li>
<li>An array of comments on the item</li>
<li>An array of annotations on the item</li>
<li>An origin object which stores
<ul>
<li>The stream id - this is the <i>feed/[feedurl]</i> that Google uses to identify the feed</li>
<li>The feed title string</li>
<li>The HTML url to the feed's homepage</li>
</ul>
</ul>
</ul>
<p><a name="labelname"></a><br />
<h2>label/[labelName]</h2>
<p>Lists all items from a given label.<br />
<strong>Parameters</strong></p>
<ul>
<li>See <a href="#feed">feed list</a></li>
</ul>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">GET http://www.google.com/reader/api/0/stream/contents/user/-/label/label?ot=1253066400&amp;r=n&amp;xt=user/-/com.google/read&amp;n=20&amp;ck=1255660064860&amp;client=myApplication</div></div>
<p><strong>Sample Output</strong> - See <a href="#feed">feed list</a></p>
<p><a name="readinglist"></a><br />
<h2>reading-list</h2>
<p>List all items in the user's reading list. This is a list of all of the items from all of the user's feeds, excluding items depending on the xt (exclude target) parameter.<br />
<strong>Parameters</strong></p>
<ul>
<li>See <a href="#feed">feed list</a></li>
</ul>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">GET http://www.google.com/reader/api/0/stream/contents/user/-/state/com.google/reading-list?ot=1253066400&amp;r=n&amp;xt=user/-/state/com.google/read&amp;n=20&amp;ck=1255660536125&amp;client=myApplication</div></div>
<p><strong>Sample Output</strong> - See <a href="#feed">feed list</a></p>
<p><a name="starred"></a><br />
<h2>starred</h2>
<p>List all items that the user has marked as "starred"<br />
<strong>Parameters</strong></p>
<ul>
<li>n=<i>[integer]</i> : The maximum number of results to return.</li>
<li>ck=<i>[unix timestamp]</i> : Use the current Unix time here, helps Google with caching.</li>
<li>client=<i>[your client]</i> : You can use the default Google client (scroll), but it doesn't seem to make a difference. Google probably uses this field to gather data on who is accessing the API, so I'd advise using your own unique string to identify your software.</li>
</ul>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">GET http://www.google.com/reader/api/0/stream/contents/user/-/state/com.google/starred?n=20&amp;ck=1255660749447&amp;client=myApplication</div></div>
<p><strong>Sample Output</strong> - See <a href="#feed">feed list</a></p>
<p><a name="broadcast"></a><br />
<h2>broadcast</h2>
<p>List all items that the user has chosen to share publicly.<br />
<strong>Parameters</strong></p>
<ul>
<li>n=<i>[integer]</i> : The maximum number of results to return.</li>
<li>ck=<i>[unix timestamp]</i> : Use the current Unix time here, helps Google with caching.</li>
<li>client=<i>[your client]</i> : You can use the default Google client (scroll), but it doesn't seem to make a difference. Google probably uses this field to gather data on who is accessing the API, so I'd advise using your own unique string to identify your software.</li>
</ul>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">GET http://www.google.com/reader/api/0/stream/contents/user/-/state/com.google/broadcast?n=20&amp;ck=1255660975267&amp;client=myApplication</div></div>
<p><strong>Sample Output</strong> - See <a href="#feed">feed list</a></p>
<p><a name="created"></a><br />
<h2>created</h2>
<p>List all notes that the user has created.<br />
<strong>Parameters</strong></p>
<ul>
<li>n=<i>[integer]</i> : The maximum number of results to return.</li>
<li>ck=<i>[unix timestamp]</i> : Use the current Unix time here, helps Google with caching.</li>
<li>client=<i>[your client]</i> : You can use the default Google client (scroll), but it doesn't seem to make a difference. Google probably uses this field to gather data on who is accessing the API, so I'd advise using your own unique string to identify your software.</li>
</ul>
<p><strong>Sample Output</strong></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">GET http://www.google.com/reader/api/0/stream/contents/user/-/state/com.google/created?n=20&amp;ck=1255661349906&amp;client=myApplication</div></div>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">{<br />
&nbsp; &nbsp; &quot;id&quot;:&quot;user/01723985652832499840/source/com.google/post&quot;,<br />
&nbsp; &nbsp; &quot;title&quot;:&quot;\&quot;post\&quot; via iamaelephant in Google Reader&quot;,<br />
&nbsp; &nbsp; &quot;self&quot;:<br />
&nbsp; &nbsp; [<br />
&nbsp; &nbsp; &nbsp; &nbsp; {&quot;href&quot;:&quot;http://www.google.com/reader/api/0/stream/contents/user/01723985652832499840/state/com.google/created?n\u003d20\u0026ck\u003d1255661572704\u0026client\u003dscroll&quot;}<br />
&nbsp; &nbsp; ],<br />
&nbsp; &nbsp; &quot;author&quot;:&quot;iamaelephant&quot;,<br />
&nbsp; &nbsp; &quot;updated&quot;:1255661564,<br />
&nbsp; &nbsp; &quot;items&quot;:<br />
&nbsp; &nbsp; [<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;crawlTimeMsec&quot;:&quot;1255661564095&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;id&quot;:&quot;tag:google.com,2005:reader/item/2dc5e875a623fe5e&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;categories&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;user/01723985652832499840/source/com.google/post&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;user/01723985652832499840/state/com.google/broadcast&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;user/01723985652832499840/state/com.google/read&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;user/01723985652832499840/state/com.google/fresh&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;published&quot;:1255661564,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;updated&quot;:1255661564,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;related&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;href&quot;:&quot;http://www.google.com/reader/shared/01723985652832499840&quot;,&quot;streamId&quot;:&quot;user/01723985652832499840/state/com.google/broadcast&quot;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;alternate&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;href&quot;:&quot;http://www.google.com/reader/item/tag:google.com,2005:reader/item/2dc5e875a623fe5e&quot;,&quot;type&quot;:&quot;text/html&quot;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;content&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;direction&quot;:&quot;ltr&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;content&quot;:&quot;this is the note text&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;author&quot;:&quot;iamaelephant&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;likingUsers&quot;:[],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;comments&quot;:[],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;annotations&quot;:[],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;origin&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;streamId&quot;:&quot;user/01723985652832499840/source/com.google/post&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;htmlUrl&quot;:&quot;http://www.google.com/reader/shared/01723985652832499840&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; ]<br />
}</div></div>
<p>That's an awful lot of information for a little note, but most of it corresponds closely to item information, so if you're unsure of how to interpret a field, have a look at the output summary for the <a href="#feed">feed/[feedurl]</a> call.</p>
<p>Phew! That mostly does it for the listing methods. There are some other minor calls I've left out for brevity, but most of what you'll want to achieve is in here, and I intend on releasing complete documentation when I have finished my .NET Google Reader API library. In my next post I'll discuss the POST methods so you can start altering the contents of your Google Reader list, star/un-star items, etc. Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
<enclosure url="http://feedproxy.google.com/~r/astronomycast/~5/4TPW83-0h4Y/AstroCast-090921.mp3" length="18470398" type="audio/mpeg" />
		</item>
		<item>
		<title>Using the Google Reader API &#8211; Part 1</title>
		<link>http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/</link>
		<comments>http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 23:35:01 +0000</pubDate>
		<dc:creator>Martin Doms</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[aggregation]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google reader]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://blog.martindoms.com/?p=101</guid>
		<description><![CDATA[Google Reader API series

Part 1 &#8211; Programming to the API
Part 2 &#8211; Listing API
Part 3 &#8211; Editing API
Google have never officially released API documentation for Google Reader, so this information is unofficial and subject to change.
When I first started looking around for API docs to interface with Google Reader, this site seemed to be pretty [...]]]></description>
			<content:encoded><![CDATA[<p>Google Reader API series</p>
<ul>
<li>Part 1 &#8211; Programming to the API</li>
<li><a href="http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/">Part 2 &#8211; Listing API</a></li>
<li><a href="http://blog.martindoms.com/2010/01/20/using-the-google-reader-api-%e2%80%93-part-3/">Part 3 &#8211; Editing API</a></ul>
<p>Google have never officially released API documentation for Google Reader, so this information is unofficial and subject to change.</p>
<p>When I first started looking around for API docs to interface with Google Reader, <a href="http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI">this site</a> seemed to be pretty much the only resource available. Unfortunately a lot of the information in that document is outdated, so I set about trying to figure out the API myself, with some success.</p>
<p>To interface with Google reader, you&#8217;ll need to collect the following things from their authentication system:</p>
<ul>
<li><strong>SID</strong> &#8211; A session ID, which remains valid until you log out</li>
<li><strong>Token</strong> &#8211; Similar to a session ID, but expires quickly. Used to access direct API calls</li>
<li><strong>Cookie</strong> &#8211; An ordinary cookie that uses your SID to authenticate your session on API calls</li>
</ul>
<p>The code samples I&#8217;m using will be in C#, but should be easily translatable to any language.</p>
<p>To get an SID, we send a GET request to https://www.google.com/accounts/ClientLogin with arguments service=reader&#038;Email=<i>[your Google username]</i>&#038;Passwd=<i>[your Google password]</i><br />
This will return some text with <i>key=value</i> pairs for LSID, SID and User. SID is the only part of this we need, so use your string library to grab this information.</p>
<p>Now that we have an SID we need a token. We send a GET request to  http://www.google.com/reader/api/0/token with a cookie we generate from the SID. The cookie information is</p>
<ul>
<li>Name: SID</li>
<li>Value: <i>[your SID]</i></li>
<li>Path: /</li>
<li>Domain: .google.com</li>
</ul>
<p>This request returns just the token text.</p>
<p>So here is the code I wrote for getting SID and token:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Net</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.IO</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF;">namespace</span> GoogleReader.<span style="color: #0000FF;">NET</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> GoogleReader<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> _sid <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> _token <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> Cookie _cookie <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> _username<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> _password<span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> GoogleReader<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> username, <span style="color: #FF0000;">string</span> password<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _username <span style="color: #008000;">=</span> username<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _password <span style="color: #008000;">=</span> password<span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; connect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">bool</span> connect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getToken<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> _token <span style="color: #008000;">!=</span> null<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> getToken<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getSid<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _cookie <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Cookie<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;SID&quot;</span>, _sid, <span style="color: #666666;">&quot;/&quot;</span>, <span style="color: #666666;">&quot;.google.com&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> url <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://www.google.com/reader/api/0/token&quot;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpWebRequest req <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>HttpWebRequest<span style="color: #000000;">&#41;</span>WebRequest.<span style="color: #0000FF;">Create</span><span style="color: #000000;">&#40;</span>url<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; req.<span style="color: #0000FF;">Method</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;GET&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; req.<span style="color: #0000FF;">CookieContainer</span> <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CookieContainer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; req.<span style="color: #0000FF;">CookieContainer</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>_cookie<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpWebResponse response <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>HttpWebResponse<span style="color: #000000;">&#41;</span>req.<span style="color: #0000FF;">GetResponse</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>var stream <span style="color: #008000;">=</span> response.<span style="color: #0000FF;">GetResponseStream</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StreamReader r <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> StreamReader<span style="color: #000000;">&#40;</span>stream<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _token <span style="color: #008000;">=</span> r.<span style="color: #0000FF;">ReadToEnd</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> getSid<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> requestUrl <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;https://www.google.com/accounts/ClientLogin?service=reader&amp;Email={0}&amp;Passwd={1}&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _username, _password<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpWebRequest req <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>HttpWebRequest<span style="color: #000000;">&#41;</span>WebRequest.<span style="color: #0000FF;">Create</span><span style="color: #000000;">&#40;</span>requestUrl<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; req.<span style="color: #0000FF;">Method</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;GET&quot;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpWebResponse response <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>HttpWebResponse<span style="color: #000000;">&#41;</span>req.<span style="color: #0000FF;">GetResponse</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>var stream <span style="color: #008000;">=</span> response.<span style="color: #0000FF;">GetResponseStream</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StreamReader r <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> StreamReader<span style="color: #000000;">&#40;</span>stream<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> resp <span style="color: #008000;">=</span> r.<span style="color: #0000FF;">ReadToEnd</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">int</span> indexSid <span style="color: #008000;">=</span> resp.<span style="color: #0000FF;">IndexOf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;SID=&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #FF0000;">4</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">int</span> indexLsid <span style="color: #008000;">=</span> resp.<span style="color: #0000FF;">IndexOf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;LSID=&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _sid <span style="color: #008000;">=</span> resp.<span style="color: #0000FF;">Substring</span><span style="color: #000000;">&#40;</span>indexSid, indexLsid <span style="color: #008000;">-</span> 5<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>From here were can make interface calls (I plan to document the complete set of API calls in the very near future, but for now I&#8217;ll give a couple of examples). To add a subscription, make an HTTP POST to http://www.google.com/reader/api/0/subscription/quickadd?client=scroll with POST arguments quickadd=<i>[url of feed]</i>&#038;T=<i>[your token]</i> and don&#8217;t forget to include your cookie. I wrote a couple of quick helper methods for making POST and GET calls first:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF;">private</span> HttpWebResponse httpGet<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> requestUrl, <span style="color: #FF0000;">string</span> getArgs<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> url <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;{0}?{1}&quot;</span>, requestUrl, getArgs<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpWebRequest request <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>HttpWebRequest<span style="color: #000000;">&#41;</span>WebRequest.<span style="color: #0000FF;">Create</span><span style="color: #000000;">&#40;</span>url<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request.<span style="color: #0000FF;">Method</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;GET&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request.<span style="color: #0000FF;">CookieContainer</span> <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CookieContainer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request.<span style="color: #0000FF;">CookieContainer</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>_cookie<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> <span style="color: #000000;">&#40;</span>HttpWebResponse<span style="color: #000000;">&#41;</span>request.<span style="color: #0000FF;">GetResponse</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">catch</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// handle error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> null<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> HttpWebResponse httpPost<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> requestUrl, <span style="color: #FF0000;">string</span> postArgs<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> buffer <span style="color: #008000;">=</span> Encoding.<span style="color: #0000FF;">GetEncoding</span><span style="color: #000000;">&#40;</span>1252<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetBytes</span><span style="color: #000000;">&#40;</span>postArgs<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpWebRequest request <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>HttpWebRequest<span style="color: #000000;">&#41;</span>WebRequest.<span style="color: #0000FF;">Create</span><span style="color: #000000;">&#40;</span>requestUrl<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request.<span style="color: #0000FF;">Method</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;POST&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request.<span style="color: #0000FF;">CookieContainer</span> <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CookieContainer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request.<span style="color: #0000FF;">CookieContainer</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>_cookie<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request.<span style="color: #0000FF;">ContentType</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;application/x-www-form-urlencoded&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request.<span style="color: #0000FF;">ContentLength</span> <span style="color: #008000;">=</span> buffer.<span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stream PostData <span style="color: #008000;">=</span> request.<span style="color: #0000FF;">GetRequestStream</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostData.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span>buffer, 0, buffer.<span style="color: #0000FF;">Length</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostData.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> <span style="color: #000000;">&#40;</span>HttpWebResponse<span style="color: #000000;">&#41;</span>request.<span style="color: #0000FF;">GetResponse</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">catch</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//handle error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> null<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>Now for the add subscription code:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">bool</span> AddFeed<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> feedUrl<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> data <span style="color: #008000;">=</span> <span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;quickadd={0}&amp;T={1}&quot;</span>, feedUrl, _token<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> url <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://www.google.com/reader/api/0/subscription/quickadd?client=scroll&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpWebResponse response <span style="color: #008000;">=</span> httpPost<span style="color: #000000;">&#40;</span>url, data<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>response <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">return</span> false<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> true<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div></div>
<p>We can add a label to a feed by POSTING to http://www.google.com/reader/api/0/subscription/edit?client=scroll with arguments a=user/-/label/<i>[new label]</i>&#038;s=feed/<i>[feed url]</i>&#038;ac=edit&#038;T=<i>[token]</i> like so:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">bool</span> AddLabelToFeed<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> label, <span style="color: #FF0000;">string</span> feedUrl<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> data <span style="color: #008000;">=</span> <span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">Format</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;a=user/-/label/{0}&amp;s=feed/{1}&amp;ac=edit&amp;T={2}&quot;</span>, label, feedUrl, _token<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> url <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://www.google.com/reader/api/0/subscription/edit?client=scroll&quot;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpWebResponse response <span style="color: #008000;">=</span> httpPost<span style="color: #000000;">&#40;</span>url, data<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>response <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">return</span> false<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> true<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div></div>
<p>There are of course listing methods for getting feeds. So far I&#8217;ve only been able to figure out how to get feed information in JSON format, but if anyone knows how to grab XML data please leave a comment. To list items we send a GET request to http://www.google.com/reader/api/0/stream/contents/user/-/state/com.google/reading-list?ck=<i>[current UNIX time]</i> . Of course there are many more otpional arguments for all of these methods, which I will be documenting. Here&#8217;s the list code:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> ListAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> url <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;http://www.google.com/reader/api/0/stream/contents/user/-/&quot;</span> <span style="color: #008000;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666;">&quot;state/com.google/reading-list&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> args <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;ck={0}&quot;</span>, getUnixTimeNow<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpWebResponse response <span style="color: #008000;">=</span> httpGet<span style="color: #000000;">&#40;</span>url, args<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stream str <span style="color: #008000;">=</span> response.<span style="color: #0000FF;">GetResponseStream</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StreamReader sr <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> StreamReader<span style="color: #000000;">&#40;</span>str<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> s <span style="color: #008000;">=</span> sr.<span style="color: #0000FF;">ReadToEnd</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Handle JSON data in s</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sr.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div></div>
<p>getUnixTimeNow() is a small helper method I wrote for getting the current Unix time:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF;">private</span> <span style="color: #FF0000;">long</span> getUnixTimeNow<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeSpan ts <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>DateTime.<span style="color: #0000FF;">UtcNow</span> <span style="color: #008000;">-</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> DateTime<span style="color: #000000;">&#40;</span>1970, 1, 1, 0, 0, 0<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">long</span> unixTime <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">long</span><span style="color: #000000;">&#41;</span>ts.<span style="color: #0000FF;">TotalSeconds</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> unixTime<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div></div>
<p>This has been a small taste of what&#8217;s to come as I work my way through this API. Stay tuned for more. If you want to get hacking on it yourself, the easiest way is to download <a href="http://www.fiddler2.com/fiddler2/">Fiddler</a>, a great web debugging tool, and watch the HTTP requests as you use Google Reader.<br />
<br /><strong><a href="http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/">Part 2</a> now available.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>JD&#8217;s The Perils of Travel Video transcribed</title>
		<link>http://blog.martindoms.com/2009/08/12/jds-man-stories-europe-video-transcribed/</link>
		<comments>http://blog.martindoms.com/2009/08/12/jds-man-stories-europe-video-transcribed/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 21:05:28 +0000</pubDate>
		<dc:creator>Martin Doms</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[comedy]]></category>
		<category><![CDATA[reblog]]></category>
		<category><![CDATA[transcript]]></category>

		<guid isPermaLink="false">http://blog.martindoms.com/?p=55</guid>
		<description><![CDATA[The following is the text transcript from a video posted at JD&#8217;s Man Stories titled The Perils of Travel. This is not my content, but I felt the video was such a terrible medium for such a great story that a text only version was necessary. I hope you enjoy it as much as I [...]]]></description>
			<content:encoded><![CDATA[<p>The following is the text transcript from a video posted at <a href="http://jdsmanstories.blogspot.com/">JD&#8217;s Man Stories</a> titled <strong>The Perils of Travel</strong>. This is <strong>not my content</strong>, but I felt the video was such a terrible medium for such a great story that a text only version was necessary. I hope you enjoy it as much as I did, and be sure to visit JD&#8217;s blog, it&#8217;s a lot of fun. Video at the bottom.</p>
<p>During the Summer of 2007, I had the opportunity to backpack around Europe for 2 weeks.</p>
<p>I talked about it often before I left. My girlfriend however, although great in many respects, was not the world&#8217;s greatest listener.</p>
<p>I left on Friday June 1st. Despite even calling her to say goodbye the night before, she never realized I left. When I arrived home 2 weeks later, I had several emails from her, waiting in my inbox&#8230;</p>
<blockquote><p>
June 1st 11:31am<br />
<strong>Subject:</strong> Maddy Babe!</p>
<p>*Smooch*</p>
<p>Hey doll, me and the girls are gonna hit up the maddy tonight. I&#8217;ll call you in a bit, you and the boys should come out too.</p>
<p>Love ya,<br />
Em
</p></blockquote>
<blockquote><p>
June 1st 4:40m<br />
<strong>Subject: </strong>Come out come out, hehe</p>
<p>Hey hun, me again.</p>
<p>Tried calling you cell a few times today but it kept going right to your voice mail. You&#8217;re not screening me are you? <img src='http://blog.martindoms.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Give me a call when you get this.
</p></blockquote>
<p>My cell was off for the entire trip so that I wouldn&#8217;t get insane roaming charges in Europe.</p>
<blockquote><p>
June 2nd 9:12am<br />
<strong>Subject:</strong> Missed you! (frowny face)</p>
<p>JDddddddddd&#8230; I missed you last night! There were these two suepr creepy guys who kept trying to talk to us all night. I let the one guy buy me a drink and as soon as he handed it to me I told him he reminds me of my boyfriend, ha ha ha.</p>
<p>I tried you cell again but again no answer, having cell problems dear? Anyway, Maria and me are going out for brunch to try and get over our hangovers&#8230;. tonight, you and me, dinner at your place.</p>
<p>Call me today.</p>
<p>Later Baber,<br />
Em
</p></blockquote>
<blockquote><p>
June 3rd 10:33am<br />
<strong>Subject:</strong> Uh&#8230; hello&#8230;?</p>
<p>JD, wtf. Why are you not responding to my calls and emails? Where are you?! I waited all night for you to get in touch with me. I&#8217;m not happy here babe&#8230; call me ASAP!!!
</p></blockquote>
<blockquote><p>
June 3rd 8:41pm<br />
<strong>Subject:</strong> (no subject)</p>
</blockquote>
<blockquote><p>
June 5th 5:50pm<br />
<strong>Subject:</strong>  WTF</p>
<p>What the fuck is going on?! Why are you avoiding me? You&#8217;re not answering your cell, you won&#8217;t return me texts&#8230; JD wtf?!</p>
<p>I know you&#8217;re around! Your friend Jeremy is such a bullshitter. When he said he hadn&#8217;t seen you all weekend I could hear you talking in the background!<br />
I thought you were different fuck nut!</p>
<p>Last chance&#8230; call me tonight with the best excuse of your life or I walk asshole.
</p></blockquote>
<p>Apparently she call one of my friend to find out where I was on the weekend. I have no idea what she&#8217;s talking about here though.</p>
<blockquote><p>
June 5th 8:11pm<br />
<strong>Subject:</strong> Read this asshole!</p>
<p>I tried calling you, I&#8217;ve tried calling your friends, you mom. What the fuck did I do? Was it just time? Time to dump me? You could at least tell it to my face asshole.</p>
<p>We&#8217;re through&#8230; don&#8217;t call me, don&#8217;t text me, don&#8217;t bother now. You&#8217;ll never know what you lost, I was the one, and now I feel sorry for you because you&#8217;ll never have that again. I feel so sorry for you, ha ha ha.
</p></blockquote>
<p>She left messages at my mom&#8217;s demanding I call her back. My mom would&#8217;ve called her to tell her I was in Europe except she didn&#8217;t leave her number and my mom doesn&#8217;t have it.</p>
<p>I just got dumped while I was on a different continent than my girlfriend&#8230;</p>
<p>I&#8217;ve been in Europe for only 5 days&#8230;</p>
<p>And the emails are just beginning.</p>
<blockquote><p>
June 8th 1:07am<br />
<strong>Subject:</strong> (no subject)</p>
<p>I hate you.
</p></blockquote>
<blockquote><p>
June 10th 3:44am<br />
<strong>Subject:</strong> FUUUUUUUUUUCK U</p>
<p>Hey fuck fcee,</p>
<p>remmembe r that friend of mine that I was you were jealous of who said that nuffin ever will happen with well I was crying with him about you and he told me how amazing I was, how he always thought so and so i fucked him to show you I&#8217;m right! Now who&#8217;s the stuipd one? I can&#8217;t get any guy I want and whatr are you doing just sitting at home crying over how you lost me? Well don&#8217;t cry for me because you&#8217;ve already lost me asswhole! Ha ha ha ha ha
</p></blockquote>
<p>I would say I&#8217;ve been cheated on&#8230; but technically I&#8217;m single at this point</p>
<blockquote><p>
June 10th 4:01am<br />
<strong>Subject:</strong> (no subject)
</p></blockquote>
<blockquote><p>
June 12th 2:20pm<br />
<strong>Subject:</strong> Read ASAP</p>
<p>JD, call me, we need to talk.
</p></blockquote>
<blockquote><p>
June 12th 8:11pm<br />
<strong>Subject:</strong> Just listen&#8230;</p>
<p>Ok fine, you don&#8217;t want to call me then just listen. I&#8217;m mad and hurt right now. I really felt something between us and now you&#8217;ve gone and thrown it all away and I have no idea why&#8230; JD, we were amazing together weren&#8217;t we? </p>
<p>We always had fun, and I tried to be so easy going and happy with yo. We were the coupel that could spend and evening out with our friends or laze about on the couch and either way end it all in fantastic sex and confessions of love. I know that something has happened to change all that, but you have to admit that you still feel something for me. To deny that is to deny your very soul.</p>
<p>I know you&#8217;ll call me tonight. We have a lot to discuss. A lot of bad and good. It may not change thing and we may still be broken up, but at least you owe me a conversation. A chance.</p>
<p>Em
</p></blockquote>
<p>I&#8217;ve been in Europe for 12 days. I am coming home on Saturday. On this day I go shopping in Rome and get a necklace for Em and write a postcard to my grandparents.</p>
<blockquote><p>
June 14th 7:01am<br />
<strong>Subject:</strong>  I tried&#8230;</p>
<p>I tried to reach out to you JD, I really did. But I take back all those nice things I said. I&#8217;m glad we&#8217;re broken up. You&#8217;re boring as shit to be with. I pretended so many times to like the stupid shows you like, to watch the stupid movies you like, to enjoy spending time with your asinine friends. I&#8217;ve moved on. I realize that you are not the right person for me in any way whatsoever. You bring out the worst traits in me and I&#8217;m a million times better without you.</p>
<p>I&#8217;m bringing a bunch of your stuff to your mom&#8217;s house. So long JD, I&#8217;d like to say it was fun but it really wasn&#8217;t. Believe me when I say I never want to hear from you again.</p>
<p>Em
</p></blockquote>
<blockquote><p>
June 14th 8:21am<br />
<strong>Subject:</strong> OPEN FIRST!!! DO NOT READ ANY OTHER EMAILS!!!</p>
<p>If you love me, you will delete every email I&#8217;ve sent over the past week without reading it. JD please I am begging you that when you get back you do not read any email but this one. We&#8217;ve all made mistakes while you&#8217;ve been away. I can explain it all to you, call me ASAP. I love you with all my heart and soul!</p>
<p>Em
</p></blockquote>
<p>When she went to my mom&#8217;s house to drop off my stuff, she bumped into my mom&#8230; my mom told her I was in Europe until Saturday.</p>
<p>I read the emails&#8230; Em and I are no longer together. I learned two important lessons from this whole ordeal&#8230;</p>
<p>1. Careful when you date passionate people, because passion swings both ways. Sometimes they&#8217;ll love you, but other times they&#8217;ll hate you. And when they hate you&#8230; boy do they hate you.</p>
<p>2. When you go to Europe for 2 weeks, leave your fucking phone on.</p>
<p>jdsmanstories.blogspot.com</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/qg-heCy0CbQ&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;hl=en&#038;feature=player_embedded&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/qg-heCy0CbQ&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;hl=en&#038;feature=player_embedded&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.martindoms.com/2009/08/12/jds-man-stories-europe-video-transcribed/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Regular Expressions in C – Having Trouble with the Pipe ‘&#124;’ Character?</title>
		<link>http://blog.martindoms.com/2009/08/09/regular-expressions-in-c-%e2%80%93-having-trouble-with-the-pipe-%e2%80%98%e2%80%99-character/</link>
		<comments>http://blog.martindoms.com/2009/08/09/regular-expressions-in-c-%e2%80%93-having-trouble-with-the-pipe-%e2%80%98%e2%80%99-character/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 01:45:58 +0000</pubDate>
		<dc:creator>Martin Doms</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c programming]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://blog.martindoms.com/?p=21</guid>
		<description><![CDATA[I was working on an assignment for my C class recently and spent an inordinate amount of time solving a simple problem with regular expressions. Hopefully this quick post will help save someone else the frustration.
Let’s say you have the regular expression Cat&#124;Dog&#124;Horse (should match Cat OR Dog OR Horse). You compile the regex using
char* [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on an assignment for my C class recently and spent an inordinate amount of time solving a simple problem with regular expressions. Hopefully this quick post will help save someone else the frustration.</p>
<p>Let’s say you have the regular expression <font face="Courier">Cat|Dog|Horse</font> (should match Cat OR Dog OR Horse). You compile the regex using</p>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333;">char</span><span style="color: #339933;">*</span> regStr <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Cat|Dog|Horse&quot;</span><span style="color: #339933;">;</span><br />
regex_t reg<span style="color: #339933;">;</span><br />
regcomp<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>reg<span style="color: #339933;">,</span> regStr<span style="color: #339933;">,</span> REG_ICASE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>So far so good. But now we try testing this regex against the word Dog</p>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333;">int</span> result <span style="color: #339933;">=</span> regexec<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>reg<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Dog&quot;</span><span style="color: #339933;">,</span> 0<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> 0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Result: %d&quot;</span><span style="color: #339933;">,</span> result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>And it fails! Well don’t despair, the solution is simple. The pipe ‘|’ operator in C regular expression is only included in the extended set of regex operators. When compiling the regular expression using regcomp simply use <font face="Courier">REG_EXTENDED</font> in the last argument. If you still want your regular expression to be case insensitive you can pipe two arguments together, like</p>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">regcomp<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>reg<span style="color: #339933;">,</span> regStr<span style="color: #339933;">,</span> REG_ICASE<span style="color: #339933;">|</span>REG_EXTENDED<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Hope that helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.martindoms.com/2009/08/09/regular-expressions-in-c-%e2%80%93-having-trouble-with-the-pipe-%e2%80%98%e2%80%99-character/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Be Careful with Random Numbers in .NET</title>
		<link>http://blog.martindoms.com/2009/08/09/be-careful-with-random-numbers-in-net/</link>
		<comments>http://blog.martindoms.com/2009/08/09/be-careful-with-random-numbers-in-net/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 01:43:21 +0000</pubDate>
		<dc:creator>Martin Doms</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[random number]]></category>
		<category><![CDATA[static methods]]></category>

		<guid isPermaLink="false">http://blog.martindoms.com/?p=18</guid>
		<description><![CDATA[[private void ColorWindowButton_Click(object sender, RoutedEventArgs e)
{
// todo fix this, crashes if window previously closed
_colorView.Show();
}[


I’m working on a little game for some friends that involves rolling five dice on a board and came across an interesting little problem, which I’ll illustrate with a very small dummy program. Here we have a simple die class for creating [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">[private void ColorWindowButton_Click(object sender, RoutedEventArgs e)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">// todo fix this, crashes if window previously closed</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">_colorView.Show();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}[</div>
<p><span style="font-family: 'Verdana,Geneva,Arial,Sans-serif'; color: #444444;"></p>
<p><span style="line-height: 17px;"></p>
<p>I’m working on a little game for some friends that involves rolling five dice on a board and came across an interesting little problem, which I’ll illustrate with a very small dummy program. Here we have a simple die class for creating individual die objects:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF;">namespace</span> DiceRoller<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #FF0000;">class</span> Die<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> Face <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF;">private</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">const</span> <span style="color: #FF0000;">int</span> maxRoll <span style="color: #008000;">=</span> <span style="color: #FF0000;">6</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> Random ran <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Random<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Constructor</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> Die<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Roll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Roll the die</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> Roll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Face <span style="color: #008000;">=</span> ran.<span style="color: #0000FF;">Next</span><span style="color: #000000;">&#40;</span>maxRoll<span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> Face<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>And a small console program that will instantiate 5 dice and roll all five of them, 5 times.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF;">namespace</span> DiceRoller<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #FF0000;">class</span> Program<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Die<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> dice <span style="color: #008000;">=</span> <span style="color: #000000;">&#123;</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Die<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Die<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Die<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Die<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Die<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> j <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> j <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">5</span><span style="color: #008000;">;</span> j<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> dice.<span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span>dice<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Roll</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span style="color: #0000FF;">ReadLine</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>And here is the output.<br />
<img src="http://blog.martindoms.com/wp-content/uploads/2009/08/dice_thumb.jpg" alt="Output" title="Output" width="687" height="351" class="alignnone size-full wp-image-11" /></p>
<p>Whoa! Not very random. The default .NET random number generator appears to be using the system time to generate the random numbers. Because our calls to <font face="Courier">ran.Next()</font> are so close together, we’re getting mostly the same result. There are a couple of ways to fix this. One option is to tell the thread to stop executing for some time before the roll, by using <font face="Courier">Thread.Sleep(10)</font> at the start of the <font face="Courier">Roll()</font> method. This works, but it’s ugly.</p>
<p>A better solution is to make the <font face="Courier">Random</font> object in the <font face="Courier">Die</font> class a static member. This way, every die will share the same <font face="Courier">Random</font>, and so each time <font face="Courier">ran.Next()</font> is called it iterates the random number on the same object. This solution is perfect. You only need to change one line in the Die class:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> Random ran <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Random<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>And the result:<br />
<img src="http://blog.martindoms.com/wp-content/uploads/2009/08/dice2_thumb.jpg" alt="Output" title="Output" width="81" height="174" class="alignnone size-full wp-image-12" /></p>
<p>Perfect! In this case it was easy to see the problem and very simple to fix, but the moral of the story is, be careful with the RNG if you’re using it for anything non-trivial, especially when you’re generating multiple numbers from different instances of Random.</p>
<p></span><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.martindoms.com/2009/08/09/be-careful-with-random-numbers-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elephantcatch &#8211; WPF podcast catcher and aggregator</title>
		<link>http://blog.martindoms.com/2009/08/08/elephantcatch-wpf-podcast-catcher-and-aggregator/</link>
		<comments>http://blog.martindoms.com/2009/08/08/elephantcatch-wpf-podcast-catcher-and-aggregator/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 08:29:10 +0000</pubDate>
		<dc:creator>Martin Doms</dc:creator>
				<category><![CDATA[Code Projects]]></category>

		<guid isPermaLink="false">http://blog.martindoms.com/?p=71</guid>
		<description><![CDATA[This program aggregates podcast RSS feeds, automatically checks them for new items and downloads the audio and video files. Built from the ground up in WPF using the Model-View-ViewModel pattern. UI colors and transparency can be customized. This software is still in very early stages and contains many bugs.
Download! (requires Windows XP, Vista or 7, [...]]]></description>
			<content:encoded><![CDATA[<p>This program aggregates podcast RSS feeds, automatically checks them for new items and downloads the audio and video files. Built from the ground up in WPF using the Model-View-ViewModel pattern. UI colors and transparency can be customized. This software is still in very early stages and contains many bugs.</p>
<p><strong>Download!</strong> (requires Windows XP, Vista or 7, .NET Framework 3.5 SP1)<br />
<a href="http://websvn.martindoms.com/filedetails.php?repname=ElephantCatch&#038;path=%2FECSetup%2FRelease%2FECSetup.msi">Location 1</a><br />
<a href="http://svn.martindoms.com/ecmvvm/ECSetup/Release/ECSetup.msi">Location 2</a></p>
<p><strong>Get the code!</strong><br />
<a href="http://websvn.martindoms.com/listing.php?repname=ElephantCatch&#038;">WebSVN</a><br />
<a href="http://svn.martindoms.com/ecmvvm/">SVN</a></p>
<p><img src="http://blog.martindoms.com/wp-content/uploads/2009/08/ec1.JPG" alt="ElephantCatch UI" title="ElephantCatch UI" width="826" height="573" class="alignnone size-full wp-image-72" /></p>
<div id="attachment_73" class="wp-caption alignnone" style="width: 853px"><img src="http://blog.martindoms.com/wp-content/uploads/2009/08/ec2.JPG" alt="Customize the UI colors" title="UI Customization" width="843" height="741" class="size-full wp-image-73" /><p class="wp-caption-text">Customize the UI colors</p></div>
<p><img src="http://blog.martindoms.com/wp-content/uploads/2009/08/ec3.JPG" alt="ElephantCatch" title="ElephantCatch" width="839" height="418" class="alignnone size-full wp-image-74" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.martindoms.com/2009/08/08/elephantcatch-wpf-podcast-catcher-and-aggregator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ElephantCatch, WinForms version</title>
		<link>http://blog.martindoms.com/2009/08/08/elephantcatch-winforms-version/</link>
		<comments>http://blog.martindoms.com/2009/08/08/elephantcatch-winforms-version/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 08:27:13 +0000</pubDate>
		<dc:creator>Martin Doms</dc:creator>
				<category><![CDATA[Code Projects]]></category>

		<guid isPermaLink="false">http://blog.martindoms.com/?p=96</guid>
		<description><![CDATA[This is an early version of my ElephantCatch podcatching software, written in WinForms. This is more stable than my newer WPF version, but less flashy and uses more memory. Supports OPML import/export of feeds.
Download! (requires Windows XP, Vista or 7)
Location 1
Location 2
Get the code!
WebSVN
SVN

]]></description>
			<content:encoded><![CDATA[<p>This is an early version of my ElephantCatch podcatching software, written in WinForms. This is more stable than my newer <a href="http://blog.martindoms.com/2009/08/08/elephantcatch-wpf-podcast-catcher-and-aggregator/">WPF version</a>, but less flashy and uses more memory. Supports OPML import/export of feeds.</p>
<p><strong>Download!</strong> (requires Windows XP, Vista or 7)<br />
<a href="http://websvn.martindoms.com/filedetails.php?repname=ElephantCatch+Winforms&#038;path=%2FPodCatcher3%2Fbin%2FDebug%2Fapp.publish%2Fsetup.exe">Location 1</a><br />
<a href="http://svn.martindoms.com/ecwf/PodCatcher3/bin/Debug/app.publish/setup.exe">Location 2</a></p>
<p><strong>Get the code!</strong><br />
<a href="http://websvn.martindoms.com/listing.php?repname=ElephantCatch+Winforms">WebSVN</a><br />
<a href="http://svn.martindoms.com/ecwf/">SVN</a></p>
<p><img src="http://blog.martindoms.com/wp-content/uploads/2009/08/ecwf.JPG" alt="ecwf" title="ecwf" width="838" height="692" class="alignnone size-full wp-image-97" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.martindoms.com/2009/08/08/elephantcatch-winforms-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Asteroids!</title>
		<link>http://blog.martindoms.com/2009/08/08/asteroids/</link>
		<comments>http://blog.martindoms.com/2009/08/08/asteroids/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 08:27:04 +0000</pubDate>
		<dc:creator>Martin Doms</dc:creator>
				<category><![CDATA[Code Projects]]></category>

		<guid isPermaLink="false">http://blog.martindoms.com/?p=78</guid>
		<description><![CDATA[My first ever Java game, the classic Asteroids. What else is there to say? Arrow keys to move, space to fire.
Download! (requires Java Runtime v5 or higher)
Location 1
Location 2
Get the code!
WebSVN
SVN

]]></description>
			<content:encoded><![CDATA[<p>My first ever Java game, the classic Asteroids. What else is there to say? Arrow keys to move, space to fire.</p>
<p><strong>Download!</strong> (requires Java Runtime v5 or higher)<br />
<a href="http://websvn.martindoms.com/filedetails.php?repname=Asteroids&#038;path=%2Fdist%2FAsteroids.jar">Location 1</a><br />
<a href="http://svn.martindoms.com/asteroids/dist/Asteroids.jar">Location 2</a></p>
<p><strong>Get the code!</strong><br />
<a href="http://websvn.martindoms.com/listing.php?repname=Asteroids&#038;">WebSVN</a><br />
<a href="http://svn.martindoms.com/asteroids/">SVN</a></p>
<p><img src="http://blog.martindoms.com/wp-content/uploads/2009/08/ast2.JPG" alt="ast2" title="ast2" width="839" height="663" class="alignnone size-full wp-image-79" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.martindoms.com/2009/08/08/asteroids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
