How to Develop Facebook Apps More Easily with SDKs

Facebook’s SDKs perform two important functions. Depending on the SDK, they load libraries of scripting functions that browsers can use to execute script code not otherwise available to the browser, or they provide programming environments that make writing code for a specific platform, such as Apple’s iOS mobile platform, easier. Some SDKs perform both functions.

Facebook has five SDKs, two for writing code in popular web-scripting languages (JavaScript and PHP), and two for writing platform-specific code for iOS (iPods, iPhones, and iPads), and Google’s popular Android operating system (OS) used on many smartphones and tablets. For the sake of this discussion, the SDKs are separated into two categories, placing the web-scripting language SDKs in one group and the OS SDKs in the other.

Typically, web-scripting languages are used for web apps, and OS SDKs are used for creating mobile apps, or standard apps that don’t usually require a web page to run in. You probably already have several mobile apps running on your smartphone or tablet.

Web-scripting SDKs

The two most popular scripting languages on the web are JavaScript, a client-side language, and PHP, a server-side language. Client-side scripts are executed by the browser, and server-side scripts are run by the server. Each has pluses and minuses. PHP is better at data manipulation, such as querying databases and displaying data. JavaScript works better for visual and behavioral effects, such as simple animations, and displaying menus and buttons.

Another advantage to server-side scripts is that the server processes the code, removing much of the stress from the browser and device resources, which can be beneficial on mobile devices. In addition, JavaScript is not supported on all mobile devices, especially older smartphones and feature phones. Server-side scripts can help ensure that your pages and apps work on a wider range of devices.

Facebook’s JavaScript SDK

The JavaScript SDK supports client-side calls to Facebook’s server-side API, allowing your apps and web pages to take advantage of most Facebook features, including the Graph API and dialog boxes. It also processes XFBML for exploiting social plugins, as well as providing a mechanism for your canvas pages to communicate with Facebook.

To use the Facebook JavaScript SDK, all you have to do is load it on top of your web pages and canvas pages. Your app can then use XFBML to interact with the Facebook API. Depending on what your app does inside Facebook, each application will require slightly different code to load the SDK. The basic script for loading it goes below the <body> tag in your pages.

<div id="fb-root"></div>
<script>
 window.fbAsyncInit = function() {
 FB.init({
  appId  : 'YOUR_APP_ID', // App ID
  channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
  status  : true, // check login status
  cookie  : true, // enable cookies to allow the server to access the session
  xfbml  : true // parse XFBML
 });
 // Additional initialization code here
 };
 // Load the SDK Asynchronously
 (function(d){
  var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
  js = d.createElement('script'); js.id = id; js.async = true;
  js.src = "//connect.facebook.net/en_US/all.js";
  d.getElementsByTagName('head')[0].appendChild(js);
 }(document));
</script>

Check here detailed information on the JavaScript SDK.

PHP SDK

Because the PHP SDK loads server-side scripts, it consists of several PHP pages that you download from github and upload to your web server (the server that hosts your app or web pages on which you want to include Facebook objects).

To use the PHP SDK, you need to acquire an app ID from Facebook’s developer app. You need a lot more info to set up and use this SDK.

Mobile app–scripting SDKs

Facebook also provides SDKs for popular mobile devices, such as Google's Android operating system (OS), found on many of today's smartphones and tablets, as well as Apple’s iOS, used on iPhones, iPod touches, and iPads.

iOS SDK

The iOS SDK allows you to create apps for Apple’s handheld devices: the iPod Touch, iPhone, and iPad. Like the PHP SDK, the iOS SDK must be downloaded from github. You must also register it with Facebook and install it, which requires an app ID that you acquire from Facebook.

Technically, the iOS SDK is a Facebook app itself. It contains dialog boxes and debugging tools to help you through the app development process, but it does not completely eliminate the need for programming skills. Get the URL for the iOS Getting Started page, which contains links to multiple other iOS SDK technical documents.

image0.jpg

Android SDK

The Android SDK allows you to develop Facebook apps for mobile devices (smartphones and tablets) that run on Google’s popular Android OS, which powers hundreds of devices. You must download the Android SDK from github, register it with Facebook, and install it.

If you’ve used Google’s Android SDK, you'll see some similarities in this one. The Android SDK provides several dialog boxes for walking you through the development process, including a code editor, a debugger, and a compiler. Check here for full installation and usage details for the Android SDK.

image1.jpg
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com