
How can I get started programming a Facebook app?This is a guest article written by freelance programmer Ville-Matti Hakanpää In this brief introductory tutorial I will go through some basic aspects of Facebook application development. The work itself is basic app programming, but it's a whole new world and environment. If you have a wonderful idea, Facebook can work as a great distribution channel for you. Heck, even a bad idea can get some attention fast! Start out with the most basic of questions, though: what makes a good app? That's the first and most common question people are asking or they should be asking. The best way to start when you're trying to decide what to develop is to look through all the other applications what are inside Facebook already. Facebook applications are listed and rated by users, so there's a feedback loop there too that tells you the kind of things people find useful and engaging. The most popular one for now is a game called Farmville, with 73 million active users per month, which is over double the next two combined. In general, games are very popular inside Facebook. For me that reveals few things. First of all people like to play games. Entertainment is a hot topic. Second of all, Facebook doesn't have any fun games to offer for own users, hence the popularity of third party apps. The most popular "ordinary" application is Causes, which provides an opportunity to donate money to different non-profit projects. While charity is important, it doesn't comply with useful, "needed-daily" idea. Think about non-Facebook programs like Google. Would you survive without it? You might, but it makes your life so much easier that you probably choose to use it anyway, many times during the day. If you can create something like that for Facebook, well, you'll have gold in your hands. Technically you have two different possible approaches you can choose from. You can use Facebook's own technology (FBML, FBJS and FQL) or you can use an API client. Difference is that when you are using FBML (Facebook Markup Language) for example, you are mainly using Facebook's server and its resources. This way you can save you own server. Using API is the complete opposite. Let's compare these. First let's create a "Hello World" application with PHP5 API client: <?php
// include the Facebook client library require_once '<YOUR_PHP_CLIENT_DIRECTORY>/facebook.php'; // define your API Key and secret $facebook_config['api_key'] = '<YOUR_APPLICATIONS_API_KEY>'; $facebook_config['secret'] = '<YOUR_APPLICATIONS_SECRET_KEY>'; // create the Facebook object $facebook = new Facebook($facebook_config['api_key'], $facebook_config['secret']); // require user to be logged in' $user = $facebook->require_login(); // define your callback URL $callback_url = 'http://<URL_TO_THE_APPLICATION_AT_YOUR_END>/'; ?> Hello World! And same thing with FBM: <fb:if-is-app-user>
Hello World! <fb:else> <fb:redirect url="http://www.facebook.com/login.php?v=1.0&api_key=<YOUR_API_KEY>&canvas=http://< URL_TO_THE_APPLICATION_AT_YOUR_END >" /> </fb:else> </fb:if-is-app-user> Both examples will check if the user has approved the application and then prints out words "Hello World". While FBML looks and is much more simple way to do things, it has huge limitations when you compare it to PHP for example. FBML is wary easy to compare with HTML which was the starting point when FBML was developed. Can you build rich web applications using HTML only? Hardly... The question what should be asked is not which one I should be using, but how to use them both. Let's create a invitation form to show my point: <?php
<USE THE SAME PHP CODE AS IN FIRST EXAMPLE> ?> <fb:request-form type="MyInvite" content="I say this is a one cool app!<fb:req-choice url='http://apps.facebook.com/greattestapp/' label='Confirm' />"> <fb:multi-friend-selector actiontext="Tell all your friends! Tell the whole bunch!" /> </fb:request-form> This looks rather simple, but the mechanism behind it is really helpful and sophisticated. You are gathering all your friends and bringing them into a clickable list. From this point you can grow it to whatever you like with smaller resources required than a normal web application. Now your program could invite more people and it has requested the basic privileges. That's hardly enough but it's a good start. Now the real developing begins. Use your knowledge of PHP and start learning those Facebook Technologies what I mentioned. Anytime you get stuck, there is a place to go. For like minded people The Facebook Developers Forum provides the support you need. While Facebook development is rather new and is partly in beta state, you will need help and extra revealing information. Go to the forums now and start digging. Author ille-Matti Hakanpää is a freelance PHP programmer. His personal website concentrates on PHP training with Facebook in mind.
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon
Categorized:
Articles and Reviews
,
CGI Scripts and Web Site Programming
,
MySpace, Facebook, Twitter and Social Network Help
(Article 9263)
Tagged: app programming, facebook, facebook apps, farmville, php, programming Previous: How can I print sideways in Microsoft Word for Windows? Next: Is there any way to play Foursquare on my laptop? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.
Rather amazingly, there are no comments on this article yet.
I have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
![]()
Search
Find just the answers you seek from among our 2300+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Industry News and Trade Shows Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Book Links
|