Start your clocks and lets get cracking.
1. Create your demo page. (2 minutes)
This is the page that the user will see on their canvas page. If you already have a page that you want to use, great. If not, then just copy this code for a guessing game.
iRandom = Math.floor(Math.random()*10)+1;
alert('OK, I am thinking of a number between 1 and 10');
var yourGuess = document.getElementById('myGuess').value;
alert('Well done! You guessed it.');
<div>Enter your guess between 1 and 10: <input type=text id='myGuess' name='myGuess'>
<input type='button' onClick='Guess()' value='Guess'>
<input type='button' onClick='Restart()' value='Start Again'>
2. Install the Developer Application.
It’s not going to win any awards, but it gets the job done. Save the file somewhere on your website as ‘guess.htm’. Mine is saved at http://gathadams.com/guess.htm
Ok, now log into Facebook.
3. Create the Application.
This allows you to create applications.
Click the ‘create application’ link4. Fill in the Application details.
5. Add the application
There are heaps of fields you can enter, I am just going over the ones you need to get this demo working.
Application Name: Any name you want. I used ‘Guessing Game’.
Terms of Service checkbox: Check it.
Click ‘Optional Fields’.
Callback Url: This should be the root directory that your ‘guess.htm’ page is found at. You must also add a ‘/’ at the end. I used ‘http://gathadams.com/’.
Canvas Page URL: This is the most confusing part, and wasted me heaps of time. What they want you to enter is basically a directory name for your applcaition. The name must be 7 characters or more, and must be unique from other Facebook applications. I used ‘guessab’ (so you can’t). When you add ‘http://apps.facebook.com/’ to the front you have the Canvas page URL.
NOTE: If you use upper case in the Canvas Page URL, it will be converted to lower case automatically. Also, case is important, so if you use upper case in your links later on THEY WON’T WORK.
Tick ‘Use iframe’: This means that your canvas pages will use an iframe.
Application Type: Leave it at ‘website’.
Can your application be added on Facebook?: Tick ‘Yes’.
Application Description: I used ‘Cool guessing game’. If you disagree, feel free to use your own description.
Default FMBL: We will fill this out last, so leave it for the moment.
Default Profile Box Column: Tick ‘Narrow’.
Side Nav URL:OK, here is where we put a link in the side nav to the canvas page.
The full canvas page has the format:
http://apps.facebook.com/< value entered in Canvas Page URL>/
So for me, the full canvas page URL is:
Facebook maps ‘http://apps.facebook.com/guessV1/’ to your Callback URL, so what is loaded in the iframe is:
Note: Notice there is no ‘/’ inserted in guess.htm, that is why you have to put it in your Callback URL.
Anyway, now we can go back to
Default FMBL: This is the text that will go on the user’s profile. Lets just put another link to our game on the Canvas page. I entered:
Lets play a <a href=’http://apps.facebook.com/guessab/guess.htm’>Guessing Game</a>
From within ‘My Applications’, click on ‘View About Page’ for your new application. Then click ‘Add Application’, and confirm this.
6. Done! (Lets play)
Click on the link in either the left nav panel or the main profile panel and knock yourself out.
7. Submit your URL (Lets play)
If you want to share your game with others, go to the Activity, click the Submit button. Now enter the name of your game and the URL in the text box.