Facebook Application Development
Do you have a Facebook page? If you do, you are among the 600 million users who actively use the social-networking service. I'll admit I initially resisted the temptation to join Facebook. After all, I've got e-mail, instant messaging and VoIP. What do I need with yet another form of communication? Eventually, temptation got the better of me, and I gave it a try. For the record, I also experimented with MySpace and Twitter, but those sites just didn't seem to do anything for me. These days, every time I go to my computer, I check my servers, my e-mail and my Facebook.
I never thought it would get to this point, but it turns out that Facebook is a surprisingly powerful piece of technology. So far, I've connected with friends from church, college, high school, previous jobs and some of my son's activities. I've managed to reconnect with my best friend from high school after 20 years. I've even managed to reconnect with my best friend from the third grade! Since I'm 43 years old, I think that's quite an accomplishment. Like I said, it's very powerful technology.
But for me, there's more. I also get links to blogs and news articles from like-minded friends as well as pointers to breaking news that's of interest to me. Many times, I've heard about events on Facebook before I saw them on TV or read about them in the newspaper. Lately, I've been investigating ways to use Facebook to promote my new business, and I'm sharing some of what I've found in this article.
First, let's take care of some of the easy stuff. Everyone's probably been to a Web site and seen a Facebook "Like" button. When users click on this button, they are asked to log in to Facebook, if they're not already. Then, the button click causes a brief message to be added to users' Facebook pages, indicating that they like the particular Web site. All of the users' Facebook friends then can see this message. Assuming that many of one's friends share the same interests, this is a very simple way to get a message out to potentially interested people.
Adding a Like button to a Web site is as easy as embedding a little HTML code into your page. Facebook even has a wizard to help customize the button: https://developers.facebook.com/docs/reference/plugins/like.
When I played with this wizard, I was given code that looked like the code shown in Listing 1. This code results in a Web browser displaying something that resembles Figure 1.
Listing 1. Like Button Code
<iframe src="http://www.facebook.com/plugins/like.php?href=
↪www.linuxjournal.com&send=true&layout=
↪standard&width=450&show_faces=true&action=
↪like&colorscheme=light&font&height=80"
↪scrolling="no" frameborder="0" style="border:none;
↪overflow:hidden; width:450px; height:80px;"
↪allowTransparency="true"></iframe>

Figure 1. Like Button
Facebook also provides methods that allow a Web site to post to users' Facebook pages as well as adding a person or page to their friends list. These methods are documented at https://developers.facebook.com/docs/reference/dialogs.
Before I go any further, let me pass on a little tidbit of information I came across while researching this article. Facebook supports a primitive chat function that allows users to exchange interactive messages with their friends. This chat function is based on the XMMP protocol, which is the same protocol that Google Talk and Jabber use. The details are documented at https://developers.facebook.com/docs/chat. Essentially, you need to know your Facebook user name and password. Then, you prepend your user name to @chat.facebook.com to form a Jabber ID. When I plugged this information in to Kopete, I was able to chat with my Facebook friends using Kopete. I also was able to get real-time updates when my friends logged in and out of Facebook.
Facebook also provides a powerful method of querying its database for various types of information. Using a language called Facebook Query Language (FQL), you can ask for all kinds of information about a Facebook user, subject to access restrictions. The easiest way to do this is to use the HTTP GET access method. This method allows you to execute a query using a standard HTTP GET. The results are returned in XML format. All you have to do is append your query to the end of this URL: https://api.facebook.com/method/fql.query?query=.
For example, if you had a user ID number and wanted to find the user's full name, you would use something like this:
https://api.facebook.com/method/fql.query?query=select
↪name from user where uid=1690577964
Amazingly, your results look like this:
<![CDATA[
<fql_query_response list="true">
<user>
<name>Mike Diehl</name>
</user>
</fql_query_response>
]]>
FQL requires that you specifically list each of the fields in which you are interested. That means you can't simply use select * from... as you would be tempted to do in a language like SQL. So, it's important to know what tables and columns are available to you. This is well documented at: https://developers.facebook.com/docs/reference/fql.
At the risk of duplicating what's already on the Web site, here's a list of a few of the more interesting tables that you can query (from the Web site):
-
comment: query this table to obtain comments associated with one or more feed comment XIDs.
-
connectioncomment: query this table to return a user's friends and the Facebook pages to which the user is connected.
-
friend: query this table to determine whether two users are linked together as friends.
-
like: query this table to return the user IDs of users who like a given Facebook object (video, note, link, photo or photo album).
-
notification: query this table to get the notifications for the current session user—that is, any notification that appears on http://www.facebook.com/notifications.php.
-
profile: query this table to return certain (typically publicly) viewable information from a user's profile or Facebook page that is displayed in a story.
-
status: query this table to return one or more of a user's statuses.
-
stream: query this table to return posts from a user's stream or the user's profile.
-
user: query this table to return detailed information from a user's profile.
You can query against quite a few other tables, and I've not fully explored what information is available. I can tell you that e-mail addresses and phone numbers aren't readily available using this query method. Also, users are able to set permissions that determine what can be retrieved.
That said, you could use these methods in a server-side program to get all kinds of information about a user. But, the real power comes from being able to perform these queries on the client's computer via JavaScript. (I'll show you how that's done, shortly.)
Mike Diehl is a freelance Computer Nerd specializing in Linux administration, programing, and VoIP. Mike lives in Albuquerque, NM. with his wife and 3 sons. He can be reached at mdiehl@diehlnet.com
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
| Introduction to MapReduce with Hadoop on Linux | Jun 05, 2013 |
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Linux Systems Administrator
- Validate an E-Mail Address with PHP, the Right Way
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Introduction to MapReduce with Hadoop on Linux
- RSS Feeds
- One advantage with VMs
45 min 6 sec ago - about info
1 hour 18 min ago - info
1 hour 19 min ago - info
1 hour 20 min ago - info
1 hour 22 min ago - info
1 hour 23 min ago - abut info
1 hour 24 min ago - info
1 hour 25 min ago - info
1 hour 27 min ago - info
1 hour 28 min ago
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?



Comments
Sounds really interesting.
Sounds really interesting. I'm new in fan page development platform. Hope you guys very friendly people. I just need to learning several development apps. Thanks!
NIce info
hi i am new in the development field your blog read i have create my pluging in the facebook.
plugin
How did you do that?
I've had issues with LINUX
and its ability to render 3D graphics in AutoCAD. Any suggestions?
Really? ... '↪' character used in API calls?
In listing 1, you've got the entity RARRHK ('↪') all over your iframe element. Does the Facebook API really use that, or is this some weird CMS data corruption going on in linuxjournal.com?
Yup.
Looks like the transition from print to CMS has corrupted the listing. Simply delete the entity and you get what SHOULD be there.