Indometric


Posts Tagged ‘HTML’

Jul 27
Wednesday

The Elements of the Facebook Platform

Filed under Social Network

As stated previously articles, the Facebook platform consists of five components: a markup language derived from HTML (Facebook Markup Language), a REST API for treatment communication between Facebook and your application, a SQL-style language for interacting with Facebook data (Facebook Query Language), a scripting language (Facebook JavaScript), and a set of client libraries for different programming languages. I’ll cover these five fundamentals in the following sections.

Facebook Markup Language

Facebook
Facebook
If you’ve ever developed in ColdFusion or JSTL (or other tag-based programming language), you’ll find working with the platform’s Facebook Markup Language (FBML) very natural. If you’re new to tag-based programming, just reckon of FBML as fancy HTML tags, because each interaction starts and ends with a tag. But, to distinguish between HTML and Facebook commands, you prefix the tags with fb: as you would if you were using multiple DTDs/schemas in XHTML. By using the FBML tag set, Facebook abstracts a lot of complicated code and makes many of the routine procedures nearly effortless. For example, to add a link to your application’s help pages on your dashboard (the navigational tabs that go across the top), you simply need to add the following lines:

<fb:dashboard>
<fb:help href="help.php">Application Help</fb:help>
</fb:dashboard>

REST API Calls

Facebook API calls are grouped into eight action categories. These calls are really wrappers for more sophisticated FQL interactions with the Facebook back end but are helpful bits of code that speed up the enhancement of your application. These calls include the following:

  • facebook.auth provides basic authentication checks for Facebook users.
  • facebook.feed provides methods to post to Facebook news feeds.
  • facebook.friends provides methods to query Facebook for various checks on a user’s friends.
  • facebook.notifications provides methods to send messages to users.
  • facebook.profile allows you to set FBML in a user’s profile.
  • facebook.users provides information about your users (such as content from the user’s profile and whether they are logged in).
  • facebook.actions provides ways to access Facebook actions.
  • facebook.groups provides methods to access information for Facebook groups.
  • facebook.photos provides methods to interact with Facebook photos.

Facebook Query Language

The Facebook Query Language (FQL) is a SQL-style language particularly calculated to allow developers to interact with Facebook information. Facebook allows you to interact with nine separate “tables” to query information frankly. You have access to the following:

  • user
  • friend
  • group
  • group_member
  • event
  • event_member
  • photo
  • album
  • phototag

I’ll get into the specifics of the information you have access to in these “tables” later in next article, but suffice to say, Facebook exposes a lot of information to you for your application. And, like most SQL implementations, some additional functions allow you to take a few shortcuts when you request user information:

  • now() returns the current time.
  • strlen(string) returns the length of the string passed to the function.
  • concat(string1, string2,…, stringN) concatenates N strings collectively.
  • substr(string, start, length) returns a substring from a given string.
  • strpos(haystack, needle) returns the position of the character needle in the string haystack.
  • lower(string) casts the given string to lowercase.
  • upper(string) casts the given string to uppercase.

To write FQL, you follow basic SQL syntax. For example, to wring my name and picture from Facebook, you would write a simple query like so:

SELECT name, pic
FROM user
WHERE uid = 7608007

The previous snippet, when executed by the Facebook platform, will return a structure (in a format that you define in your call) with a URL to the image of the profile image for user 7608007. Calls like these are helpful in charitable you granular control of the information you get back from the API.

Facebook JavaScript

To minimize the threat of cross-site scripting (XSS) attacks, Facebook implemented its own JavaScript for developers who really want, or need, to use JavaScript in their applications. Facebook scrubs (removes) much of the JavaScript you can add to your application, but by using Facebook JavaScript (FBJS) you can still enrich the user’s experience. Facebook formally released FBJS 1.0 in September 2007. If you’re well versed in JavaScript, you’ll pick this up promptly (or perhaps find it maddening). The following is a quick example of how you can grant a modal dialog box to your users:

<a href="#" onclick="new Dialog().showMessage('Dialog', 'This is the help message
for this link');return fake">Show Dialog Box</a>

When processed through the Facebook platform, a user will be shown the modal dialog box represented in Figure 1-1 after clicking the Show Dialog Box hyperlink. Not terrible for a single line of code!

Client Libraries

The Facebook platform provides many tools to access information, but you are responsible
for providing your own business logic through some other language. Facebook facilitates
this through “official” client libraries for both PHP and Java that grant convenient
methods to access the Facebook application. But, not everyone in the universe uses
Java and PHP exclusively. To help the rest of the programmers who want to develop their
own Facebook application, client libraries are available for the following languages:

  • ActionScript
  • ASP.NET
  • ASP (VBScript)
  • ColdFusion
  • C++
  • C#
  • D
  • Emacs Lisp
  • Lisp
  • Perl
  • PHP (4 and 5)
  • Python
  • Ruby
  • VB .NET
  • Windows movable

This complement of languages must take care of just about most developers today. And although these client libraries are not “officially” supported by Facebook (meaning they won’t answer your questions about using them), they are posted by the company with at least some implicit approval of life the “officially unofficial” client libraries. By the way, I’m still waiting for them to include a library for Assembly.

All entries filed under this archive


The Palm Pre Phone-Does It Live Up to the Hype?
no responses - Posted 10.03.09
THE PALM PRE smartphone ($200 with a twoyear contract from Sprint) isn't perfect, but its WebOS operating system is clean, engaging, and intuitive. The phone's main shortcomings relate to hardware. Hardware The glossy-black Pre has a curved slider body that's dominated by a 3.1-inch, 320-by-480-pixel capacitive: touch display. At 3.9 by 2.3 ...continue
Artisteer: A Revolutionary Approach to Modern Web Design
2 responses - Posted 09.05.09
These days, whether you're working on a static website, dynamic application or content management system, the final appearance of your pages comes down to cascading style sheets (CSS). Artisteer is designed to reinvent the way that CSS is handled, and itdoes so with considerable success. To understand what's so radical about ...continue
Run Regular and Seasonal Promotions
4 responses - Posted 07.24.09
To create interest in your site and brand or build personal relationships, regular promotions can really help. People like getting a break, or even better, free stuff. Depending upon what you’re promoting and to whom, the type of promotions you want to run will vary. Table below describes several scenarios and ...continue
Use Opt-In E-mail Newsletters to Drive Traffic
no responses - Posted 07.15.09
Despite the scourge of spam and viruses that have hit e-mail users in the past years, e-mail remains the killer application. E-mail newsletters are undeniably powerful tools to build audience and encourage real relationships between you and your site visitors and customers. The key to avoiding guerrilla tactics in e-mail advertising ...continue
Using Keywords in Text and Keeping URL Short
1 response - Posted 07.08.09
After looking at headings, many search engines will begin grabbing your text for descriptions. For sites that aren’t built structurally and use tables for content, you’re really playing Russian roulette trying to assume which content the engine will grab. However, if you are following well-structured markup practices, the first place most ...continue
Targeting Keywords for Meta Elements
1 response - Posted 07.02.09
By placing keywords into a meta element within your documents (a common practice), you enable search engines looking for this information to catalog your keywords quickly. Keywords can help with ranking because you are able to catalog your site based on descriptive words or series of words that define your ...continue
Complete Guide to Web Site Marketing
10 responses - Posted 07.02.09
What if you created a Web site and nobody came? You don’t want your sites to end up obscure and unused. No doubt you’veread about meta tags and how they can help your sites get ranked better; and just about everyone using the Web is aware of the annoyances related ...continue
Creating PHP Variables
no responses - Posted 06.26.08
That's not a typoPHP lets you create variable variables. A variable variable is one that holds the name of a variable. Here's how it works: you create a variable named, say, $apples: continue


All content and source © 2010 Indometric. All rights reserved. See our Privacy Policy and DMCA Information