<?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>BPulse == Ben Parsons</title>
	<atom:link href="http://www.bpulse.co.uk/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bpulse.co.uk</link>
	<description>Web development from London</description>
	<lastBuildDate>Wed, 04 May 2011 13:34:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Kiss Academy 2011</title>
		<link>http://www.bpulse.co.uk/portfolio/web/kiss-academy-2011</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/kiss-academy-2011#comments</comments>
		<pubDate>Mon, 18 Apr 2011 13:34:18 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[blackberry]]></category>
		<category><![CDATA[kiss]]></category>
		<category><![CDATA[sqlserver]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=184</guid>
		<description><![CDATA[Kiss Academy gives fans of Kiss the opportunity to learn more about the work done by Kiss through workshops and advice from recognised mentors. Entrants are required to select which workshops they&#8217;d like to be involved in, then write about &#8230; <a href="http://www.bpulse.co.uk/portfolio/web/kiss-academy-2011">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-1home.png"><img src="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-1home-150x150.png" alt="" title="kissacademy2011-1home" width="150" height="150" class="alignleft size-thumbnail wp-image-192" /></a><a href="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-2workshops.png"><img src="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-2workshops-150x150.png" alt="" title="kissacademy2011-2workshops" width="150" height="150" class="alignleft size-thumbnail wp-image-193" /></a><a href="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-3mentors.png"><img src="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-3mentors-150x150.png" alt="" title="kissacademy2011-3mentors" width="150" height="150" class="alignleft size-thumbnail wp-image-194" /></a><br />
<br clear="all" /><br />
<a href="http://academy.totalkiss.com" target="_blank">Kiss Academy</a> gives fans of Kiss the opportunity to learn more about the work done by Kiss through workshops and advice from recognised mentors. Entrants are required to select which workshops they&#8217;d like to be involved in, then write about why they&#8217;re the most suitable choice.</p>
<p>The development consisted primarily of an entry form with some JavaScript customisation and a second, smaller entry form. Additionally, the project required a custom Twitter feed, the implementation of which required building a server-side component to retrieve and format the data. A post with more technical information about the Twitter component is forthcoming.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/kiss-academy-2011/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using ASP.NET to read the Facebook signed_request object passed to iframe tabs</title>
		<link>http://www.bpulse.co.uk/blog/using-asp-net-to-read-the-facebook-signed_request-object-passed-to-iframe-tabs</link>
		<comments>http://www.bpulse.co.uk/blog/using-asp-net-to-read-the-facebook-signed_request-object-passed-to-iframe-tabs#comments</comments>
		<pubDate>Wed, 13 Apr 2011 15:24:00 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[fbml]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=141</guid>
		<description><![CDATA[Facebook recently announced that they are phasing out FMBL in favour of iframe tabs for pages. This article discusses how to extract information from the signed_request parameter passed into the iframe using Json.NET LINQ to JSON. Getting Started Firstly, if &#8230; <a href="http://www.bpulse.co.uk/blog/using-asp-net-to-read-the-facebook-signed_request-object-passed-to-iframe-tabs">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Facebook <a href="http://developers.facebook.com/blog/post/462" target="_blank">recently announced</a> that they are phasing out FMBL in favour of iframe tabs for pages. This article discusses how to extract information from the signed_request parameter passed into the iframe using <a href="http://james.newtonking.com/pages/json-net.aspx" target="_blank">Json.NET LINQ to JSON</a>.</p>
<h2>Getting Started</h2>
<p>Firstly, if you don&#8217;t already have one, create a new app using the <a href="http://www.facebook.com/developers/apps.php" target="_blank">Facebook developers app</a>. Once your app is registered, select your app in the Developer app and click &#8220;Edit Settings&#8221;, then go to the &#8220;Facebook Integration&#8221; tab. In the &#8220;Page Tabs&#8221; section, give the name you&#8217;d like for your tab, make sure the type is set to &#8220;iframe&#8221;, then give the Tab URL. Secure and Edit URLs are optional.</p>
<p style="text-align: center;"><img class="size-full wp-image-153 aligncenter" title="Facebook Page Tabs" src="http://www.bpulse.co.uk/wp-content/uploads/2011/04/pagetabs.png" alt="Facebook Page Tabs Settings" width="707" height="212" /></p>
<p>Go back to the &#8220;My Apps&#8221; page in the Facebook developers app and select your app. Click to go to the Application Profile Page, then click &#8220;Add to My Page&#8221; and select your page from the resulting dialog. This whole process is covered in more detail on the <a href="http://developers.facebook.com/docs/guides/canvas/#tabs" target="_blank">Facebook developers documentation</a>.</p>
<blockquote><p>If you find yourself getting an IIS 405 error (&#8220;HTTP verb used to access this page is not allowed&#8221;) make sure you specify the full path to the page you&#8217;re looking for. For example, using Web Forms, http://mydomain.com/folder will usually render http://mydomain.com/folder/Default.aspx when accessed from the browser. However, since Facebook is POSTing to the url you gave, IIS throws an error.</p></blockquote>
<h2>Reading signed_request</h2>
<p>Now onto the fun stuff. <a href="http://developers.facebook.com/docs/authentication/signed_request/" target="_blank">So it is written</a>, Facebook makes a POST to your page, and in doing so sends a signed_request value. See the previous link for more detail, but in short, the value is a string made up of a signature, a period (&#8220;.&#8221;) and a Base64-encoded JSON object. We&#8217;re interested in that JSON object, so we extract it from the string, the convert it from Base64 to a JSON object.</p>
<pre style="width: 100%; overflow: scroll;">string payload = Request.Form["signed_request"].Split('.')[1];
var encoding = new UTF8Encoding();
var decodedJson = payload.Replace("=", string.Empty).Replace('-', '+').Replace('_', '/');
var base64JsonArray = Convert.FromBase64String(decodedJson.PadRight(decodedJson.Length + (4 - decodedJson.Length % 4) % 4, '='));
var json = encoding.GetString(base64JsonArray);</pre>
<p>Now we have a string containing the JSON object, we can use the <a href="http://james.newtonking.com/projects/json/help/SelectToken.html" target="_blank">Json.NET LINQ TO JSON</a> functions to create a JObject containing the information:</p>
<pre>var o = JObject.Parse(json);</pre>
<p>Now we can query this object using SelectToken&#8230;</p>
<pre>bool liked = (bool)o.SelectToken("page.liked");</pre>
<p>&#8230;to extract information about the user, including whether or not they liked the page, their locale, and their age range. Facebook uses a range for ages to replace the <a href="http://developers.facebook.com/docs/reference/fbml/#visibility-on-profile" target="_blank">fbml visibility</a> tags.</p>
<h2>Conculsion</h2>
<p>Complete code:</p>
<pre style="width: 100%; overflow: scroll;">using Newtonsoft.Json.Linq;
using System.Text;

public partial class Page_Default : System.Web.UI.Page
{
    protected string output = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        output = "Whole thing:" +Request.Form["signed_request"];
        output += "Second part:" + Request.Form["signed_request"].Split('.')[1];

            try
            {
                string payload = Request.Form["signed_request"].Split('.')[1];
                var encoding = new UTF8Encoding();
                var decodedJson = payload.Replace("=", string.Empty).Replace('-', '+').Replace('_', '/');
                var base64JsonArray = Convert.FromBase64String(decodedJson.PadRight(decodedJson.Length + (4 - decodedJson.Length % 4) % 4, '='));
                var json = encoding.GetString(base64JsonArray);
                var o = JObject.Parse(json);

                output += "Decoded:" + json;

                bool liked = (bool)o.SelectToken("page.liked");

                output += "Liked:" + liked.ToString();
            }
            catch (Exception ex)
            {
                output += "Extract failed: " + ex.Message;
            }
    }
}</pre>
<p>And this is the result:</p>
<p><a href="http://www.bpulse.co.uk/wp-content/uploads/2011/04/testpage.png"><img class="aligncenter size-full wp-image-171" title="Test Page" src="http://www.bpulse.co.uk/wp-content/uploads/2011/04/testpage.png" alt="Test Page Output" width="727" height="512" /></a></p>
<p>Part of the code in this article was adapted from <a href="http://stackoverflow.com/questions/3433252/how-to-decode-oauth-2-0-for-canvas-signed-request-in-c" target="_blank">this answer on Stack Overflow by Patrick Gidich</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/blog/using-asp-net-to-read-the-facebook-signed_request-object-passed-to-iframe-tabs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New control system for the &#8220;Helicopter&#8221; Game</title>
		<link>http://www.bpulse.co.uk/lab/new-control-system-for-the-helicopter-game</link>
		<comments>http://www.bpulse.co.uk/lab/new-control-system-for-the-helicopter-game#comments</comments>
		<pubDate>Tue, 09 Nov 2010 22:31:36 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[helicopter]]></category>
		<category><![CDATA[idea]]></category>
		<category><![CDATA[scrolling]]></category>
		<category><![CDATA[touch]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=128</guid>
		<description><![CDATA[An idea prototyped in Adobe Flash, for a slightly modified control system - hopefully one suitable for both touch and non-touch environments. <a href="http://www.bpulse.co.uk/lab/new-control-system-for-the-helicopter-game">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>An idea prototyped in Adobe Flash, for a slightly modified control system &#8211; hopefully one suitable for both touch and non-touch environments. The user controls a slider, which in turn affects the attitude of a moving object (helicopter, hang-glider etc.)<br />
The slider resets to zero if the user lets go.</p>
<p>[SWF to follow]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/lab/new-control-system-for-the-helicopter-game/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tic Tacs</title>
		<link>http://www.bpulse.co.uk/portfolio/web/tic-tacs</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/tic-tacs#comments</comments>
		<pubDate>Fri, 18 Jun 2010 08:49:36 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=112</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/tic-tacs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stan James</title>
		<link>http://www.bpulse.co.uk/portfolio/web/stan-james</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/stan-james#comments</comments>
		<pubDate>Fri, 18 Jun 2010 08:48:36 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[fhm]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[sqlserver]]></category>
		<category><![CDATA[stanjames]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=109</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/stan-james/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When In Rome</title>
		<link>http://www.bpulse.co.uk/portfolio/web/when-in-rome</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/when-in-rome#comments</comments>
		<pubDate>Tue, 18 May 2010 08:50:31 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[sqlserver]]></category>
		<category><![CDATA[tv]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=114</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/when-in-rome/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starbucks Discoveries</title>
		<link>http://www.bpulse.co.uk/portfolio/web/starbucks-discoveries</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/starbucks-discoveries#comments</comments>
		<pubDate>Mon, 10 May 2010 08:54:06 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[heat]]></category>
		<category><![CDATA[heatradio]]></category>
		<category><![CDATA[podcast]]></category>
		<category><![CDATA[sqlserver]]></category>
		<category><![CDATA[starbucks]]></category>
		<category><![CDATA[thehits]]></category>
		<category><![CDATA[thehitsradio]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=116</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/starbucks-discoveries/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nokia X6</title>
		<link>http://www.bpulse.co.uk/portfolio/web/nokia-x6</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/nokia-x6#comments</comments>
		<pubDate>Thu, 18 Mar 2010 08:57:47 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[4music]]></category>
		<category><![CDATA[empire]]></category>
		<category><![CDATA[fhm]]></category>
		<category><![CDATA[grazia]]></category>
		<category><![CDATA[heat]]></category>
		<category><![CDATA[kiss]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nokia]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tv]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=119</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/nokia-x6/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sourz</title>
		<link>http://www.bpulse.co.uk/portfolio/web/sourz</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/sourz#comments</comments>
		<pubDate>Sun, 18 Oct 2009 09:09:37 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=123</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/sourz/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RAF &#8211; The Rocks</title>
		<link>http://www.bpulse.co.uk/portfolio/web/raf-the-rocks</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/raf-the-rocks#comments</comments>
		<pubDate>Fri, 18 Sep 2009 09:10:38 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=125</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/raf-the-rocks/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

