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.
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 email@example.com
- The Tiny Internet Project, Part I
- Machine Learning with Python
- SUSECON 2016: Where Technology Reigns Supreme
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Free Today: September Issue of Linux Journal (Retail value: $5.99)
- Bitcoin on Amazon! Sort of...
- Android Browser Security--What You Haven't Been Told
- Securing the Programmer
- The Many Paths to a Solution
Pick up any e-commerce web or mobile app today, and you’ll be holding a mashup of interconnected applications and services from a variety of different providers. For instance, when you connect to Amazon’s e-commerce app, cookies, tags and pixels that are monitored by solutions like Exact Target, BazaarVoice, Bing, Shopzilla, Liveramp and Google Tag Manager track every action you take. You’re presented with special offers and coupons based on your viewing and buying patterns. If you find something you want for your birthday, a third party manages your wish list, which you can share through multiple social- media outlets or email to a friend. When you select something to buy, you find yourself presented with similar items as kind suggestions. And when you finally check out, you’re offered the ability to pay with promo codes, gifts cards, PayPal or a variety of credit cards.Get the Guide