Kiss Academy 2011




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’d like to be involved in, then write about why they’re the most suitable choice.

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.

Posted in Web Development | Tagged , , , , , | Comments Off

Using ASP.NET to read the Facebook signed_request object passed to iframe tabs

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 you don’t already have one, create a new app using the Facebook developers app. Once your app is registered, select your app in the Developer app and click “Edit Settings”, then go to the “Facebook Integration” tab. In the “Page Tabs” section, give the name you’d like for your tab, make sure the type is set to “iframe”, then give the Tab URL. Secure and Edit URLs are optional.

Facebook Page Tabs Settings

Go back to the “My Apps” page in the Facebook developers app and select your app. Click to go to the Application Profile Page, then click “Add to My Page” and select your page from the resulting dialog. This whole process is covered in more detail on the Facebook developers documentation.

If you find yourself getting an IIS 405 error (“HTTP verb used to access this page is not allowed”) make sure you specify the full path to the page you’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.

Reading signed_request

Now onto the fun stuff. So it is written, 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 (“.”) and a Base64-encoded JSON object. We’re interested in that JSON object, so we extract it from the string, the convert it from Base64 to a JSON object.

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);

Now we have a string containing the JSON object, we can use the Json.NET LINQ TO JSON functions to create a JObject containing the information:

var o = JObject.Parse(json);

Now we can query this object using SelectToken…

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

…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 fbml visibility tags.

Conculsion

Complete code:

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;
            }
    }
}

And this is the result:

Test Page Output

Part of the code in this article was adapted from this answer on Stack Overflow by Patrick Gidich.

Posted in Blog | Tagged , , , , | Comments Off

New control system for the “Helicopter” Game

An idea prototyped in Adobe Flash, for a slightly modified control system – 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.)
The slider resets to zero if the user lets go.

[SWF to follow]

Posted in Lab | Tagged , , , , , | Comments Off

Tic Tacs

Posted in Web Development | Comments Off

Stan James

Posted in Web Development | Tagged , , , , , , | Comments Off

When In Rome

Posted in Web Development | Tagged , , , , , | Comments Off

Starbucks Discoveries

Posted in Web Development | Tagged , , , , , , , , , | Comments Off

Nokia X6

Posted in Web Development | Tagged , , , , , , , , , | Comments Off

Sourz

Posted in Web Development | Comments Off

RAF – The Rocks

Posted in Web Development | Comments Off

Particles Demo

Particles Demo from Ben Parsons on Vimeo.

Posted in Lab | Tagged , | Comments Off

New Site

Finally found the time to set up this site! BPulse Ltd are a London based development agency specialising in web site production. Currently under contract.

This site will be updated again with a new design.

Posted in News | Tagged | Comments Off

"Avoider" v0.1

Posted in Lab | Tagged , , , | Comments Off

Gillette Venus Embrace "Five-Star Secrets Tour" with Heat and More!

Project Gillette Venus Embrace “Five-Star Secrets Tour”
URL http://www.embrace5startour.com/
Brand(s) Heat and More!
Date March-April 2009
Employer Bauer Media (Online Advertising)
Technologies ASP.Net (C#), Adobe Flash (AS3), JavaScript (including jQuery), MS SQLServer 2005
Role Developer, front- and back-end

Posted in Web Development | Tagged , , , , , , , | Comments Off

Wanted promotion for FHM and Zoo

BPulse developed two complete games in flash for this project. These were played consecutively, so players were restricted from playing the second game until the first was completed, encouraging replays. Players were unable to access the form to enter the competition until both games were completed. Further, once the form was submitted, players were taken to a high-score board and informed that the winner would be selected only from the top players. This helped increase repeat visits.

Posted in Web Development | Tagged , , , , , , , | Comments Off

My Bloody Valentine 3D


Simple advertorial with form and video.

Posted in Web Development | Tagged , , , | Comments Off

Previous Portfolio

View prior (much older) work here.

Posted in Portfolio | Tagged | Comments Off

Camp Rock

Posted in Web Development | Tagged , , | Comments Off

Visa 2012

Campaign to reinforce VISA’s sponsorship of the 2008 Olympics. The site consisted of a design with a single form, and ran across all Big City Network websites.

Posted in Web Development | Tagged , , , , , | Comments Off

Schmap Marseille Photo Inclusion

Schmapw have seen fit to include a photo I took in the summer of 2007 of St. Charles station in their latest online travel guide. Check out the guide, or see the original.

Posted in Portfolio | Tagged | Comments Off