Skip to main content

How to write a FaceBook Application in 10 minutes June 18


Writing F8 apps is where it’s at right now. Everybody knows it. The userbase is huge and now we have a (free) API to. Everything is good….but the documentation.
I
As far as I can tell, Facebook allows you to create applications that appear to the user in 2 different areas.
1 - The profile. This the ‘main user page’ as far as Facebook is concerned. Here is where your main summary details are displayed and your comments wall. It would be great to have your widget displayed here, but the big limitation is that applications that use javascript are not allowed here (You must use FMBL, the facebook version of HTML). Too bad for me. What we can do is display a small ad to take the user to the Canvas page.
2 - The ‘Canvas page’. This is an entire page that your application gets to use (you can have multiple pages if you want). On these pages you can choose to display content from another website through an iframe, so that is what we’re going to do.
Ok, thats it for the overview. 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.


<script type=text/javascript>
var iRandom;
function Restart()
{
iRandom = Math.floor(Math.random()*10)+1;
alert('OK, I am thinking of a number between 1 and 10');
}
function Guess()
{
var yourGuess = document.getElementById('myGuess').value;
if (yourGuess>iRandom)
alert('Too High.');
if (yourGuess<iRandom)
alert('Too Low.');
if (yourGuess==iRandom)
{
alert('Well done! You guessed it.');
Restart();
}
}
</script>
<div>Enter your guess between 1 and 10: <input type=text id='myGuess' name='myGuess'>
<input type='button' onClick='Guess()' value='Guess'>
<br>
<br>
<input type='button' onClick='Restart()' value='Start Again'>
<script type=text/javascript>
Restart();
</script>

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.
2. Install the Developer Application. (1 minute)
http://developers.facebook.com/get_started.php
This allows you to create applications.

3. Create the Application. (30 seconds)
Click the ‘create application’ link
4. Fill in the Application details. (6 minutes)
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:
http://apps.facebook.com/guessab/guess.htm


Facebook maps ‘http://apps.facebook.com/guessV1/’ to your Callback URL, so what is loaded in the iframe is:


guess.htm
or
http://gathadams.com/guess.htm


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>



5. Add the application (30 seconds)
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.

If you liked this post please help spread the word by joining the HackingFreaks Fan Page on Facebook.

Comments

Popular posts from this blog

How to find who is invisible or blocked you on Google Gtalk

So guys are you ready to know that which of your friend has blocked you on google talk. Whenever you noticed a contact in your Gtalk/Google Talk has not been online for some time, have it ever crossed your mind you’ve been blocked? If you are curious in finding out who actually blocked you in Gtalk, here’s a workaround you can try. This following method we attempt to show make use of a chat client call Pidgin. STEPS TO FIND WHO IS INVISIBLE OR BLOCKED YOU ON GOOGLE CHAT: 1. Download, Install Pidgin Click here to download Pidgin chat client. If you already have Pidgin installed, you may skip this step. 2. Configure Pidgin for GtalkYou’ll probably start with the below screen. Click the Add button. "Accounts -> Manage Account" will also bring you to the same screen. Let’s add Gtalk to Pidgin. Configure Pidgin Welcome Screen Clicking Add will allow you to add new Gtalk account. The following two screenshots show what you need to fill up for Basic and Advance tab, pay...

Secrets, Hints, Tips, And Tricks To Succeed In FarmVille on Facebook

12 days ago, I happened to look over someone's shoulder when they had FarmVille open. Before then, I had brushed it off as another lame community game I didn't have time for. It was at that time that I actually saw the game being played and decided to give it a shot. Over the last 12 days, I've been so successful at the game that I felt I just had to share some of what helped me rocket past many of my Facebook friends in the game. Grab a notepad or fire up the printer, because I have some great tips and tricks to help you do as well as I am in FarmVille. Just to prove my point, here's a screen shot of my farm from just minutes ago. Not bad for 12 days. Get some friends Yeah yeah. You have a lot of friends. But are they playing FarmVille? Some things (like acquiring more land) require certain amounts of friends. Make sure you engage some of your friends to be your FarmVille neighbors. If, like me, you don't want to spam people who hate all the...

How Adsense Changed the Internet

Ever since Google came up with the master idea that is AdSense, the web has transformed in a variety of ways no one would have ever suspected. Some of these are good changes others aren't. This is a small exploration of how a brilliant marketing scheme has taken the web by storm. It deals with the changes advertisers and publishers and even website visitors have undergone ever since AdSense has become a daily part of our on-line lives. Even before AdSense came out a lot of people were advertising through AdWords. It ensured a lot of publicity through getting your site listed at the top in Google search queries. It took away a lot of the pain and price of SEO and the large amount of time you had to wait until you were finally on top. It made launching a website, a realistic way to instant profitability instead of a long term strategy with no immediate returns. Through the use of AdSense, the possibility appeared of having your ads appear on just about any site on the Internet that h...