<?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>Fresh Click Media &#187; Blogging</title>
	<atom:link href="http://www.freshclickmedia.com/blog/category/blogging/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.freshclickmedia.com</link>
	<description></description>
	<lastBuildDate>Mon, 23 Aug 2010 20:00:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>October web round-up</title>
		<link>http://www.freshclickmedia.com/blog/2008/10/october-web-round-up/</link>
		<comments>http://www.freshclickmedia.com/blog/2008/10/october-web-round-up/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 21:26:24 +0000</pubDate>
		<dc:creator>Shane</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.freshclickmedia.com/?p=98</guid>
		<description><![CDATA[<img src="http://farm4.static.flickr.com/3277/2989416849_fe142a6703_o.jpg" alt="October Web Roundup" />

It's been a busy old month, and with so much time working, I'm going to share some of the things that have interested me during October.]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm4.static.flickr.com/3171/2989434207_fd9a08c265_o.jpg" alt="October Web Roundup" /></p>
<p>It&#8217;s been a busy old month, and with so much time working, I&#8217;m going to share some of the things that have interested me during October.</p>
<h3>Windows 7 Desktop Improvements</h3>
<p>With hardware compatability issues and a reluctance from users and computer manufacturers to adopt it, Vista hasn&#8217;t perhaps been the success that Microsoft had hoped.  <a href="http://channel9.msdn.com/pdc2008/PC24/">The next version of Windows gets a preview over at channel9</a>.  There&#8217;s quite a lot of verbal fluff at the beginning, but forward through and you&#8217;ll get an idea of some of the features that&#8217;ll be present in the next version.  </p>
<h3>ASP.NET MVC Beta</h3>
<p>Many of the great frameworks, such as CodeIgniter and Ruby on Rails use a MVC architecture, and it&#8217;s a concept that many web developers are familiar with.  Maybe not so developers who have exclusively used ASP.NET for their development.  Since the introduction of <a href="http://www.microsoft.com/express/webdevelopment/Default.aspx">Visual Web Developer Express</a>, developing has become very attractive for hobby developers wishing to get to grips with ASP.NET.  I think the development of ASP.NET MVC will encourage those familiar with the pattern to give it a go.  <a href="http://weblogs.asp.net/scottgu/archive/2008/10/16/asp-net-mvc-beta-released.aspx">Scott Guthrie describes the beta release on his blog</a>.</p>
<h3>Microsoft to ship jQuery with future versions of Visual Studio</h3>
<p>I&#8217;ve been using jQuery alongside ASP.NET for several months now, and find it to be an excellent JavaScript library.  I was quite shocked that Microsoft will be <a href="http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx">distributing it with future versions</a> of Visual Studio (including express versions), providing support for it, and providing intellisense support for it.  Good on &#8216;em!</p>
<h3>Google releases Google Earth for iPhone/iPod Touch</h3>
<p>I&#8217;d definitely recommend a download of free app Google Earth &#8211; well worth taking a look.  </p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/v6BPuKaLel4"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/v6BPuKaLel4" type="application/x-shockwave-flash" wmode="transparent" width="425" height="344"></embed></object></p>
<p>For more information, head over to the <a href="http://www.google.com/mobile/apple/earth.html">Google Earth on the iPhone</a> page.</p>
<h3>Google Android Phone</h3>
<p>Following the launch of <a href="http://www.freshclickmedia.com/blog/2008/09/google-chrome-a-first-impression-or-two/">Chrome</a> , Google is pressing ahead with Mobile Device Platform <a href="http://www.android.com/">Android</a>.  Now the first handset, the <a href="http://www.google.co.uk/mobile/android/hpp.html">T-Mobile G1</a> has hit the market.  It&#8217;s certainly no looker, but Google is a company that has the expertise to change the mobile market, and I&#8217;ll be keeping an eye on things, that&#8217;s for sure.  For now though, I&#8217;ll keep my iPhone.</p>
<h3>No opera for iPhone</h3>
<p>Well well, a version of Opera has been developed for the iPhone, but Apple has refused to add it to their App Store, stating that it is too similar to Safari.  So, I won&#8217;t be holding my breath for a version of Firefox, either.  <a href="http://daringfireball.net/linked/2008/10/30/opera-iphone">John Gruber offers his opinion over at Daring Fireball</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freshclickmedia.com/blog/2008/10/october-web-round-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET Gravatar Control Update &#8211; Full Source Included</title>
		<link>http://www.freshclickmedia.com/blog/2008/06/aspnet-gravatar-control-update-full-source-included/</link>
		<comments>http://www.freshclickmedia.com/blog/2008/06/aspnet-gravatar-control-update-full-source-included/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 20:45:32 +0000</pubDate>
		<dc:creator>Shane</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Blogging]]></category>

		<guid isPermaLink="false">http://www.freshclickmedia.com/?p=88</guid>
		<description><![CDATA[<img src="http://farm4.static.flickr.com/3047/2573024373_ba7d7eb151_o.jpg" alt="Gravatar ASP.NET Control" class="header" />

With <a href="http://www.gravatar.com">gravatar</a>s now becoming ubiquitous in blogs and forums, I have developed an ASP.NET Control that encapsulates their functionality in a simple, reusable component.  It's so easy to use, you can download and be using it on your ASP.NET sites within minutes.

I've since had a lot of interest in the source code for the control, and so this post describes how the control works, as well as providing a download containing the control, as well as the full control source and example website that uses the control.]]></description>
			<content:encoded><![CDATA[<p><img class="header" src="http://farm4.static.flickr.com/3047/2573024373_ba7d7eb151_o.jpg" alt="Gravatar ASP.NET Control" /></p>
<p>With <a href="http://www.gravatar.com">gravatar</a>s now becoming ubiquitous in blogs and forums, I have developed an ASP.NET Control that encapsulates their functionality in a simple, reusable component.  It&#8217;s so easy to use, you can download and be using it on your ASP.NET sites within minutes.</p>
<p>I <a href="http://www.freshclickmedia.com/blog/2008/02/gravatar-aspnet-control/">introduced the control</a> in February of 2008, and <a href="http://www.freshclickmedia.com/blog/2008/03/gravatar-control-update/">updated the functionality</a> in March of 2008.</p>
<p>I&#8217;ve since had a lot of interest in the source code for the control, and so this post describes how the control works, as well as providing a download containing the control, as well as the full control source and example website that uses the control.</p>
<h3>OK, let me download it already!</h3>
<p><a href='http://www.freshclickmedia.com/wp-content/uploads/2008/06/gravatar.zip'>Download the Control</a> and get started.  Note that the demo projects included in the ZIP were written in Visual Studio 2005, so if you&#8217;re using Visual Studio 2008, you&#8217;ll need to convert the solution.  If you&#8217;ve not done a conversion before, just follow the instructions that Visual Studio provides.  Please also note that the solution will not open in Express Editions, since they do not support control projects.  However, you can still use the control that&#8217;s included in the ZIP file.</p>
<p>Unzip the .zip download, and you&#8217;ll have the following folder structure:</p>
<p><img src="http://farm4.static.flickr.com/3098/2573846412_eac00df65b_o.jpg" alt="Unzipped Folder structure" /></p>
<p>The root contains a small readme file, Visual Studio solution, FreshClickmedia.dll &#8211; the gravatar control assembly, Freshclickmedia.Web control project and GravatarSite website, which contains a few control examples.</p>
<p>Opening the solution in visual studio will give you this solution structure:</p>
<p><img src="http://farm4.static.flickr.com/3075/2573846554_66538578c4_o.jpg" alt="Gravatar Solution" /></p>
<p>Fire up the website, and you should see something like this:</p>
<p><img src="http://farm4.static.flickr.com/3255/2573846346_c648276ae6_o.jpg" alt="Gravatar Demo Website" /></p>
<h3>Examining the Code</h3>
<pre class="code">
    &lt;h1&gt;Gravatar Examples&lt;/h1&gt;

    &lt;h2&gt;My email address, size of 80 pixels:&lt;/h2&gt;
        &lt;fcm:Gravatar ID=&quot;Gravatar1&quot; runat=&quot;server&quot; Email=&quot;youremailaddress@domain.com&quot;
             OutputGravatarSiteLink=&quot;true&quot; Size=&quot;80&quot; /&gt;

    &lt;h2&gt;No email address, with default image (absolute url) specified:&lt;/h2&gt;
        &lt;fcm:Gravatar ID=&quot;Gravatar2&quot; runat=&quot;server&quot; Size=&quot;80&quot; DefaultImage=&quot;http://farm3.static.flickr.com/2375/2552064340_192825f989_o.jpg&quot; /&gt;

    &lt;h2&gt;Email address not associated with Gravatar, with no default image:&lt;/h2&gt;
        &lt;fcm:Gravatar ID=&quot;Gravatar3&quot; runat=&quot;server&quot; Email=&quot;thisemaildoesnotexist@freshclickmedia.com&quot; Size=&quot;80&quot;  /&gt;
</pre>
<p>The control requires an email address:</p>
<pre class="code">
&lt;fcm:Gravatar ID=&apos;Gravatar1&apos; runat=&apos;server&apos; Email=&apos;username@domain.com&apos; /&gt;
</pre>
<p>For my email address, I get the following generated HTML:</p>
<p><img src="http://farm3.static.flickr.com/2181/2283724305_24797cd8d5_o.gif" width="505" height="208" alt="Output for my email address" /></p>
<p>And if we look at the generated source:</p>
<pre class="code">
&lt;a id=&quot;Gravatar1&quot; href=&quot;http://www.gravatar.com&quot; title=&quot;Get your avatar&quot;&gt;&lt;img width=&quot;80&quot; height=&quot;80&quot; src=&quot;http://www.gravatar.com/avatar.php?gravatar_id=ccf3b8c638f15d005e5d070aeb1a3923&amp;rating=G&amp;size=80&quot; alt=&quot;Gravatar&quot; /&gt;&lt;/a&gt;
</pre>
<p>The default produces a hyperlink off to the <a href="http://www.gravatar.com">Gravatar</a> site with a title &#8220;Get your avatar&#8221;.  The image contains the MD5 email hash, a rating of &#8220;G&#8221; (suitable for all audience types), and a size of 80.</p>
<h3>Customisation</h3>
<p>The control supports a number of properties supporting the customisation of its output.</p>
<h4>Size</h4>
<p>The size property of the control can be in the range 1 to 80.  If it is outside this range, a default of 80 will be used.</dd>
<h4>MaxAllowedRating</h4>
<p>The &#8216;highest&#8217; allowed rating of image.</p>
<ul>
<li>A G rated gravatar is suitable for display on all websites with any audience type.</li>
<li>PG rated gravatars contain may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.</li>
<li>R rated gravatars may contain such things as harsh profanity, intense violence, nudity, or hard drug use.</li>
<li>X rated gravatars may contain hardcore sexual imagery or extremely disturbing violence.</li>
</ul>
<h4>OutputGravatarSiteLink</h4>
<p>True by default, determines whether a hyperlink linking to the gravatar website will be output around the image.</p>
<h4>LinkTitle</h4>
<p>&#8220;Get your avatar&#8221; by default, allows the customisation of the &#8216;title&#8217; attribute of the link (obviously doesn&#8217;t apply if OutputGravatarSiteLink property is set to false.)</p>
<h4>DefaultImage</h4>
<p>URL encoded URL, protocol included, of a GIF, JPEG, or PNG image that should be returned if either the requested email address has no associated gravatar, or that gravatar has a rating higher than is allowed by the &#8220;MaxAllowedRating&#8221; property.</p>
<p>The code snippet below shows the associated properties.</p>
<pre class="code">
&lt;fcm:Gravatar ID=&quot;Gravatar1&quot; runat=&quot;server&quot;
    Email=&quot;username@domain.com&quot;
    DefaultImage=&quot;http://www.site.com/default.jpg&quot;
    OutputGravatarSiteLink=&quot;true&quot; Size=&quot;40&quot; /&gt;
</pre>
<h3>Examining the control code</h3>
<p>The Gravatar control derives from <code>System.Web.UI.WebControls.WebControl</code> and overrides the <code>Render</code> method.</p>
<p>The various properties such as Email are all implemented as simple C# properties, with various attributes depending on the property.</p>
<pre class="code">
[Bindable(true), Category(&quot;Appearance&quot;), DefaultValue(&quot;80&quot;)]
public short Size
{
	get
	{
		return _size;
	}
	set
	{
		_size = value;
	}
}
</pre>
<p>These properties are then used in the <code>Render</code> method to write out HTML using the method&#8217;s <code>HtmlTextWriter</code> parameter.</p>
<p>The <code>Render</code> method begins by adding the default attributes to the render, ensuring that the size is within the valid range of 1 to 512, and initialises the gravatar URL:</p>
<pre class="code">
AddAttributesToRender(output);

// if the size property has been specified, ensure it is a short, and in the range
// 1..512:
try
{
    // if it's not in the allowed range, throw an exception:
    if (Size &lt; 1 || Size &gt; 512)
        throw new ArgumentOutOfRangeException();
}
catch
{
    Size = 80;
}

// default the image url:
string imageUrl = &quot;http://www.gravatar.com/avatar.php?&quot;;
</pre>
<p>If an Email address has been supplied, the <code>MD5CryptoServiceProvider</code> hashes the email and a <code>StringBuilder</code> converts this to the required format:</p>
<pre class="code">
if( !string.IsNullOrEmpty( Email))
{
    // build up image url, including MD5 hash for supplied email:
    MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();

    UTF8Encoding encoder = new UTF8Encoding();
    MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();

    byte[] hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(Email));

    StringBuilder sb = new StringBuilder(hashedBytes.Length * 2);
    for (int i = 0; i &lt; hashedBytes.Length; i++)
    {
        sb.Append(hashedBytes[i].ToString(&quot;X2&quot;));
    }

    // output parameters:
    imageUrl += &quot;gravatar_id=&quot; + sb.ToString().ToLower();
    imageUrl += &quot;&amp;rating=&quot; + MaxAllowedRating.ToString();
    imageUrl += &quot;&amp;size=&quot; + Size.ToString();
}
</pre>
<p>The final part of the method assigns a default image, if one has been specified, outputs the site ink, if required, outputs the required attributes and tags.</p>
<pre class="code">
// output default parameter if specified
if (!string.IsNullOrEmpty(DefaultImage))
{
    imageUrl += &quot;&#038;default=&quot; + HttpUtility.UrlEncode(DefaultImage);
}

// if we need to output the site link:
if (OutputGravatarSiteLink)
{
    output.AddAttribute(HtmlTextWriterAttribute.Href, &quot;http://www.gravatar.com&quot;);
    output.AddAttribute(HtmlTextWriterAttribute.Title, LinkTitle);
    output.RenderBeginTag(HtmlTextWriterTag.A);
}

// output required attributes/img tag:
output.AddAttribute(HtmlTextWriterAttribute.Width, Size.ToString());
output.AddAttribute(HtmlTextWriterAttribute.Height, Size.ToString());
output.AddAttribute(HtmlTextWriterAttribute.Src, imageUrl);
output.AddAttribute(HtmlTextWriterAttribute.Alt, &quot;Gravatar&quot;);
output.RenderBeginTag(&quot;img&quot;);
output.RenderEndTag();

// if we need to output the site link:
if (OutputGravatarSiteLink)
{
    output.RenderEndTag();
}
</pre>
<h3>Using the control on your own projects</h3>
<p>As previously mentioned, the download solution will not open properly in Express versions of Visual Studio, since it does not support control projects, but the control, included in the download is supported by all versions of Visual Studio, 2005 and later.</p>
<p>The easiest way to use the control is to add the control to the toolbox.  To do this, ensure that you are in design mode (looking at a web page), and right click on the &#8216;Standard&#8217; group header of the Toolbox.  From the context menu, select &#8220;Choose Items&#8221; and browse to the assembly (Freshclickmedia.Web.dll), and click “OK” to add.</p>
<p><img src="http://farm3.static.flickr.com/2064/2283724303_c96532e03b_o.gif" alt="Adding the control to the toolbox" width="505" height="361"  /></p>
<p>Once you&#8217;ve added the assembly, you should see the following:</p>
<p><img src="http://farm4.static.flickr.com/3170/2573127429_02824b40fd_o.jpg" alt="Gravatar Toolbox Item" /></p>
<p>From there, you can drag the control onto your page and start having fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freshclickmedia.com/blog/2008/06/aspnet-gravatar-control-update-full-source-included/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Gravatar Control Update</title>
		<link>http://www.freshclickmedia.com/blog/2008/03/gravatar-control-update/</link>
		<comments>http://www.freshclickmedia.com/blog/2008/03/gravatar-control-update/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 19:08:58 +0000</pubDate>
		<dc:creator>Shane</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Blogging]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.freshclickmedia.com/blog/2008/03/gravatar-control-update/</guid>
		<description><![CDATA[The guys over at <a href="http://www.gravatar.com">Gravatar.com</a> have been hard at work <a href="http://blog.gravatar.com/2008/03/14/big-changes-afoot/">updating their service</a>, and I've updated the <a href="http://www.freshclickmedia.com/blog/2008/02/gravatar-aspnet-control/">ASP.NET control I developed</a> to reflect the changes.]]></description>
			<content:encoded><![CDATA[<h3>Update &#8211; 12 June 2008</h3>
<p>An updated version of this post, containing full source for the control and explanation is available <a href="http://www.freshclickmedia.com/blog/2008/06/aspnet-gravatar-control-update-full-source-included/">here</a>.</p>
<h3>Original Post</h3>
<p>The guys over at <a href="http://www.gravatar.com">Gravatar.com</a> have been hard at work <a href="http://blog.gravatar.com/2008/03/14/big-changes-afoot/">updating their service</a>, and I&#8217;ve updated the <a href="http://www.freshclickmedia.com/blog/2008/02/gravatar-aspnet-control/">ASP.NET control I developed</a> to reflect the changes.</p>
<p>The maximum size of Gravatars has now been increased from 80 to 512, so there&#8217;s a code change in the Render method:</p>
<pre class="code">
// if the size property has been specified, and in the range
// 1..512:
try
{
    // if it's not in the allowed range, throw an exception:
    if (Size < 1 || Size > 512)
        throw new ArgumentOutOfRangeException();
}
catch
{
    Size = 80;
}
</pre>
<p>So, a default of 80 will still be used if the value specified is not within the 1 to 512 range, or it is not specified, but allows for a larger size.</p>
<p>The avatar.php URL serving the images <a href="http://blog.gravatar.com/2008/03/14/big-changes-afoot/">now supports abbreviation</a>, but the code in the control has not been changed.</p>
<p><img src="http://farm3.static.flickr.com/2303/2343923834_a85fa1e873_o.gif" alt="Design time view of the control" width="505" height="429" /></p>
<p>The image shows the Design time view of the control, with the width set at the default value of 80.  I&#8217;ve checked the control at 512 pixels, but my Gravatar doesn&#8217;t look too good expanded out to that size, so I&#8217;ve decided to stick at size 80 for the screenshot!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freshclickmedia.com/blog/2008/03/gravatar-control-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Gravatar ASP.NET Control</title>
		<link>http://www.freshclickmedia.com/blog/2008/02/gravatar-aspnet-control/</link>
		<comments>http://www.freshclickmedia.com/blog/2008/02/gravatar-aspnet-control/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 20:59:08 +0000</pubDate>
		<dc:creator>Shane</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Blogging]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.freshclickmedia.com/blog/2008/02/gravatar-aspnet-control/</guid>
		<description><![CDATA[I just got myself a freshclickmedia.com Gravatar over at <a href="http://site.gravatar.com/" title="Get your own Gravatar">gravatar.com</a>.  A Gravatar is a little avatar associated with an email address, and quite a few blogs use them to decorate post comments.  Signing up is easy - all you need to do is supply an email address, and image, and give your image a content rating.

The source of the gravatar image tag points to gravatar.com's image generator and includes an MD5 hash of the email address to prevent email harvesting.  A 'max rating' parameter prevents the display of unsavoury content.

There are a wide number of blogging gravatar plugins, so I decided to write an ASP.NET custom control to do the job.  Here I present the control and its features.
]]></description>
			<content:encoded><![CDATA[<h3>Update &#8211; 12 June 2008</h3>
<p>An updated version of this post, containing full source for the control and explanation is available <a href="http://www.freshclickmedia.com/blog/2008/06/aspnet-gravatar-control-update-full-source-included/">here</a>.</p>
<h3>Original Post</h3>
<p>I just got myself a freshclickmedia.com Gravatar over at <a href="http://site.gravatar.com/" title="Get your own Gravatar">gravatar.com</a>.  A Gravatar is a little avatar associated with an email address, and quite a few blogs use them to decorate post comments.  Signing up is easy &#8211; all you need to do is supply an email address, and image, and give your image a content rating.</p>
<p>The source of the gravatar image tag points to gravatar.com&#8217;s image generator and includes an MD5 hash of the email address to prevent email harvesting.  A &#8216;max rating&#8217; parameter prevents the display of unsavoury content.</p>
<p>There are a wide number of blogging gravatar plugins, so I decided to write an ASP.NET custom control to do the job.  Here I present the control and its features.</p>
<p><span id="more-80"></span></p>
<h3>Using the Control</h3>
<p>To get up and running, the control requires an email address:</p>
<pre class="code">
&lt;fcm:Gravatar ID=&apos;Gravatar1&apos; runat=&apos;server&apos; Email=&apos;username@domain.com&apos; /&gt;
</pre>
<p>For my email address, I get the following:</p>
<p><img src="http://farm3.static.flickr.com/2181/2283724305_24797cd8d5_o.gif" width="505" height="208" alt="Output for my email address" /></p>
<p>And if we look at the generated source:</p>
<pre class="code">
&lt;a id=&quot;Gravatar1&quot; href=&quot;http://www.gravatar.com&quot; title=&quot;Get your avatar&quot;&gt;&lt;img width=&quot;80&quot; height=&quot;80&quot; src=&quot;http://www.gravatar.com/avatar.php?gravatar_id=ccf3b8c638f15d005e5d070aeb1a3923&amp;rating=G&amp;size=80&quot; alt=&quot;Gravatar&quot; /&gt;&lt;/a&gt;
</pre>
<p>The default produces a hyperlink off to the <a href="http://www.gravatar.com">Gravatar</a> site with a title &#8220;Get your avatar&#8221;.  The image contains the MD5 email hash, a rating of &#8220;G&#8221; (suitable for all audience types), and a size of 80.</p>
<h3>Customisation</h3>
<p>The control supports a number of properties supporting the customisation of its output.</p>
<h4>Size</h4>
<p>The size property of the control can be in the range 1 to 80.  If it is outside this range, a default of 80 will be used.</dd>
<h4>MaxAllowedRating</h4>
<p>The &#8216;highest&#8217; allowed rating of image.</p>
<ul>
<li>A G rated gravatar is suitable for display on all websites with any audience type.</li>
<li>PG rated gravatars contain may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.</li>
<li>R rated gravatars may contain such things as harsh profanity, intense violence, nudity, or hard drug use.</li>
<li>X rated gravatars may contain hardcore sexual imagery or extremely disturbing violence.</li>
</ul>
<h4>OutputGravatarSiteLink</h4>
<p>True by default, determines whether a hyperlink linking to the gravatar website will be output around the image.</p>
<h4>LinkTitle</h4>
<p>&#8220;Get your avatar&#8221; by default, allows the customisation of the &#8216;title&#8217; attribute of the link (obviously doesn&#8217;t apply if OutputGravatarSiteLink property is set to false.)</p>
<h4>DefaultImage</h4>
<p>URL encoded URL, protocol included, of a GIF, JPEG, or PNG image that should be returned if either the requested email address has no associated gravatar, or that gravatar has a rating higher than is allowed by the &#8220;MaxAllowedRating&#8221; property.</p>
<p>The code snippet below shows the associated properties.</p>
<pre class="code">
&lt;fcm:Gravatar ID=&quot;Gravatar1&quot; runat=&quot;server&quot;
    Email=&quot;username@domain.com&quot;
    DefaultImage=&quot;http://www.site.com/default.jpg&quot;
    OutputGravatarSiteLink=&quot;true&quot; Size=&quot;40&quot; /&gt;
</pre>
<h3>Download and Get Started</h3>
<p>You can <a href='http://www.freshclickmedia.com/wp-content/uploads/2008/02/gravatar.zip' title='gravatar.zip'>download the Gravatar Custom Control here</a>.  Once you&#8217;ve extracted the assembly from the ZIP file, add to the Visual Studio toolbox by right clicking on the toolbox and selecting &#8220;Choose Items&#8221; from the context menu.  Browse to the assembly (Freshclickmedia.Web.dll), and click &#8220;OK&#8221; to add.</p>
<p><img src="http://farm3.static.flickr.com/2064/2283724303_c96532e03b_o.gif" alt="Adding the control to the toolbox" width="505" height="361"  /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.freshclickmedia.com/blog/2008/02/gravatar-aspnet-control/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<item>
		<title>Displaying Amazon lists on your blog using PHP</title>
		<link>http://www.freshclickmedia.com/blog/2007/11/displaying-amazon-lists-on-your-blog-using-php/</link>
		<comments>http://www.freshclickmedia.com/blog/2007/11/displaying-amazon-lists-on-your-blog-using-php/#comments</comments>
		<pubDate>Mon, 26 Nov 2007 13:18:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.freshclickmedia.com/blog/2007/11/displaying-amazon-lists-on-your-blog-using-php/</guid>
		<description><![CDATA[A common feature of blogs is the listing of albums or books that the author is currently enjoying. This article explains how to set up such a list in Amazon and show it on your blog using PHP and a REST web service. If you&#8217;ve visited Amazon, you&#8217;ll have noticed that every time you view [...]]]></description>
			<content:encoded><![CDATA[<p>A common feature of blogs is the listing of albums or books that the author is currently enjoying.  This article explains how to set up such a list in Amazon and show it on your blog using PHP and a REST web service.<br />
<span id="more-71"></span></p>
<p>If you&#8217;ve visited Amazon, you&#8217;ll have noticed that every time you view an item, it will be accompanied by a number of Lists, or &#8216;Listmania&#8217; items.  Each Listmania list has a title and a list of between 1 and 25 Amazon items.</p>
<p>A listmania that I&#8217;ve created can be <a href="http://www.amazon.co.uk/Currently-listening-to/lm/R2LGMJ3BF2KY9B/ref=cm_lm_byauthor_title_full">found here</a>.  As you can see, I&#8217;m quite a fan of Pink Floyd, but you can obviously put whatever you want in your own list.</p>
<p>To create your list, visit the &#8216;Your Store&#8217; tab and login.  Once you&#8217;re in, click on the &#8216;YOUR PROFILE&#8217; link that appears below the &#8216;Your store&#8217; tab (which has now changed to include your name.)  </p>
<p><img src="http://farm3.static.flickr.com/2091/2065946658_4776ecaef2_o.png" alt="Clicking on the profile link" /></p>
<p>Once the page has loaded, scroll down to the Listmania! section, and click on the &#8220;Create a Listmania!&#8221; List link.</p>
<p><img src="http://farm3.static.flickr.com/2116/2065946672_4c575c71d7_o.png" alt="Creating a listmania list" /></p>
<p>Once the page loads, you will be presented with the opportunity to create your list.  Provide a name, your qualifications (I don&#8217;t know why this is relevant), and a list of ISBN/ASINs, which uniquely identify the product (there&#8217;s more information about these on the page.)</p>
<p><img src="http://farm3.static.flickr.com/2419/2065149395_5df48ca24e_o.png" alt="Setting up the list" /></p>
<p>Once the list is set up, we&#8217;ll need to make a request to an Amazon web service to get the information to display on the site.  The first thing to do is head over to the <a href="http://www.amazon.com/gp/aws/landing.html">Amazon Web Services site</a> and sign up a free Amazon web services account.  Amazon requires that you do this because you&#8217;ll need a &#8216;developer token&#8217; before you can request any information.  </p>
<p>There&#8217;s a huge amount of documentation available on the <a href="http://www.amazon.com/gp/aws/landing.html">Amazon Web Services site</a>, but we&#8217;ll be focussing on calling the web service using <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a>.  This basically means that we&#8217;ll be making a web request to a specific URI, and getting back some XML, which we&#8217;ll parse and display on the site.</p>
<p>There a large number of web services, but our particular area of interest for retrieving our Listmania information is the <a href="http://docs.amazonwebservices.com/AWSEcommerceService/2007-01-17/">Amazon E-Commerce Service</a>.  We&#8217;ll be using the <a href="http://docs.amazonwebservices.com/AWSEcommerceService/2007-01-17/ApiReference/ListLookupOperation.html">&#8216;ListLookupOperation&#8217;</a> to get our Listmania information.  The excellent documentation specifies a number of parameters, and our URL will look something like this:</p>
<pre class="code">http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService&#038;AWSAccessKeyId=&lt;Access Key&gt;&#038;Operation=ListLookup&#038;ListType=Listmania&#038;ListId=&lt;List ID&gt;&#038;ResponseGroup=ListFull,Images</pre>
<p>The Operation parameter is set to &#8216;ListLookup&#8217; and the ListType to &#8216;Listmania&#8217;.  The ResponseGroup determines what information our XML response will contain; in this instance, we&#8217;ll get full list information with image data.  The AWSAccessKeyId is the ID you received when you signed up for the web services access, and the ListId is the ID of your listmania list (R2LGMJ3BF2KY9B for the one I described earlier.)</p>
<p>Quite a lot of XML&#8217;s returned, but a fragment is shown below:</p>
<pre class="code">
&lt;List&gt;
	&lt;ListId&gt;R2LGMJ3BF2KY9B&lt;/ListId&gt;
	&lt;ListURL&gt;http://www.amazon.co.uk/gp/richpub/listmania/fullview/R2LGMJ3BF2KY9B&lt;/ListURL&gt;
	&lt;ListName&gt;Currently listening to&lt;/ListName&gt;
	&lt;ListType&gt;Listmania&lt;/ListType&gt;
	&lt;TotalItems&gt;9&lt;/TotalItems&gt;
	&lt;TotalPages&gt;1&lt;/TotalPages&gt;
	&lt;DateCreated&gt;2007-06-08&lt;/DateCreated&gt;
	&lt;ListItem&gt;
		&lt;ListItemId&gt;RI3KA9OMXBJK39M&lt;/ListItemId&gt;
		&lt;Comment&gt;Final cut&lt;/Comment&gt;
		&lt;Item&gt;
			&lt;ASIN&gt;B0001KZM3O&lt;/ASIN&gt;
			&lt;SmallImage&gt;
				&lt;URL&gt;http://ecx.images-amazon.com/images/I/1163ZHTF2RL.jpg&lt;/URL&gt;
				&lt;Height Units="pixels"&gt;75&lt;/Height&gt;
				&lt;Width Units="pixels"&gt;75&lt;/Width&gt;
			&lt;/SmallImage&gt;
			&lt;MediumImage&gt;
				&lt;URL&gt;http://ecx.images-amazon.com/images/I/21QXBZ2M09L.jpg&lt;/URL&gt;
				&lt;Height Units="pixels"&gt;160&lt;/Height&gt;
				&lt;Width Units="pixels"&gt;160&lt;/Width&gt;
			&lt;/MediumImage&gt;
			&lt;LargeImage&gt;
			&lt;URL&gt;http://ecx.images-amazon.com/images/I/510WJ1ASB3L.jpg&lt;/URL&gt;
				&lt;Height Units="pixels"&gt;455&lt;/Height&gt;
				&lt;Width Units="pixels"&gt;455&lt;/Width&gt;
			&lt;/LargeImage&gt;
			&lt;!-- more information removed for brevity --&gt;
			&lt;ItemAttributes&gt;
				&lt;Title&gt;The Final Cut: Remastered&lt;/Title&gt;
			&lt;/ItemAttributes&gt;
		&lt;/Item&gt;
	&lt;/ListItem&gt;
&lt;/List&gt;
</pre>
<h3>Making the request for the XML using PHP</h3>
<p>To request the XML, we&#8217;ll use <a href="http://uk2.php.net/curl">CURL</a>, the Client URL Library, available since PHP version 4.0.2.  For our needs, the code is quite simple:</p>
<pre class="code">
$key = "YOURACCESSKEY";
$listID = "R2LGMJ3BF2KY9B";

$url = "http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService&#038;AWSAccessKeyId=" . $key . "&#038;Operation=ListLookup&#038;ListType=Listmania&#038;ListId=" . $listID . "&#038;ResponseGroup=ListFull,Images";    	

// make request to amazon:
$c = curl_init( $url);
curl_setopt( $c, CURLOPT_RETURNTRANSFER, 1);
$xmlResponse = curl_exec( $c);
curl_close( $c);
</pre>
<p>Initially, we define two variables to store our access key and the id of the list we want to access.  The next line creates the URL for the REST web service, building up the various parts to include the access key and list id.</p>
<p>We use CURL in the initial call to curl_init, passing in the URL for the web service.  The next line, where we call curl_setopt, is important, since it determines that the response from the URL in the curl_exec line will be assigned to a string, rather than being output directly.  This is important, since we&#8217;re going to be parsing it.  curl_exec will get the response and the final line, calling curl_close, closes the CURL session and frees the associated resources.</p>
<h3>Parsing the XML</h3>
<p>To parse the XML, we&#8217;ll use <a href="http://uk3.php.net/simplexml">SimpleXML</a>, which requires PHP5.  Using Simple XML simplifies XML handling, and fits all our needs for this example.</p>
<p>The obvious questions when parsing some XML are what are the elements that we&#8217;ll be parsing, and what are we going to output to the response.  Well, looking at the XML fragment shown above gives us some clues as for the XML structure, and for the response, I&#8217;ve decided to go for a definition list containing an album image and the album name.  For CSS styling, I&#8217;ll give the definition list a class of &#8220;listmania&#8221;.  With all this in mind, we get the following PHP code:</p>
<pre class="code">
$xml = simplexml_load_string( $xmlResponse);

$listManiaHtml = "&lt;dl class=\"listmania\"&gt;";

$itemCount = 0;

foreach( $xml-&gt;Lists-&gt;List-&gt;ListItem as $listItem)
{

		$listManiaHtml .= "&lt;dt&gt;";
		$listManiaHtml .= $listItem-&gt;Item-&gt;ItemAttributes-&gt;Title;
		$listManiaHtml .= "&lt;/dt&gt;";
		$listManiaHtml .= "&lt;dd&gt;";
		$listManiaHtml .=  "&lt;a href=\"http://www.amazon.co.uk/gp/product/" . $listItem-&gt;Item-&gt;ASIN . "\" title=\"" . $listItem-&gt;Item-&gt;ItemAttributes-&gt;Title . "\"&gt;";
		$listManiaHtml .= "&lt;img src=\"" . $listItem-&gt;Item-&gt;SmallImage-&gt;URL . "\" alt=\"" . $listItem-&gt;Item-&gt;ItemAttributes-&gt;Title . "\" /&gt;";
		$listManiaHtml .= "&lt;/a&gt;";
		$listManiaHtml .= "&lt;/dd&gt;";
}

$listManiaHtml .= "&lt;/dl&gt;";
</pre>
<p>To begin, the XML response from the REST web service is loaded using simple_xml_load_string function.  I define a variable to store the listmania output, and begin by assigning the opening tag of the definition list.</p>
<p>Using simple XML&#8217;s traversal methods, I can associate XML elements in the response directly using a chained -> syntax.  Each album is enclosed in a ListItem element, and this is referenced in the foreach loop.  Within this loop, the ListItem element&#8217;s Title, ASIN (Amazon identifier), and small image URL are extracted and appended to the listmania output variable.  The ASIN is used in a hyperlink to link directly to the album on the Amazon website.</p>
<p>Doing a simple echo on the resulting listmania variable is all that&#8217;s then required to output the semantic listmania.  Shown below is what the output looks like:</p>
<pre class="code">
&lt;dl class="listmania"&gt;
    &lt;dt&gt;The Final Cut: Remastered&lt;/dt&gt;
    &lt;dd&gt;
        &lt;a href="http://www.amazon.co.uk/gp/product/B0001KZM3O" title="The Final Cut: Remastered"&gt;
            &lt;img src="http://ecx.images-amazon.com/images/I/1163ZHTF2RL.jpg" alt="The Final Cut: Remastered" /&gt;
        &lt;/a&gt;
    &lt;/dd&gt;

    &lt;dt&gt;Libertad (Special Edn)&lt;/dt&gt;
    &lt;dd&gt;
        &lt;a href="http://www.amazon.co.uk/gp/product/B000QEIMJG" title="Libertad (Special Edn)"&gt;
            &lt;img src="http://ecx.images-amazon.com/images/I/11LmOg0O4pL.jpg" alt="Libertad (Special Edn)" /&gt;
        &lt;/a&gt;
    &lt;/dd&gt;
&lt;/dl&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.freshclickmedia.com/blog/2007/11/displaying-amazon-lists-on-your-blog-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
