O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning Facebook Application Development

Book Description

A step-by-step tutorial for creating custom Facebook applications using the Facebook platform and PHP

  • Complete guide to building Facebook applications in PHP

  • Fully illustrated with fun, functional step-by-step examples

  • Covers recent platform additions: Facebook JavaScript, Facebook AJAX

  • Create data-driven applications, employ multimedia, and more

In Detail

Using Facebook Applications, developers can add custom features to one of the most popular websites in the world. Facebook is the biggest social network among college students, and is gaining ground among professionals too. Facebook applications enable you to add new ways for users to interact with each other using Facebook.

Facebook applications are written in a server-side language, and hosted on the application developer's own server. They interface with Facebook, so that they appear to users to be part of Facebook itself.

This book shows PHP developers how to quickly get started building powerful Facebook applications, how to work with data stored in Facebook, including photos, and how to handle multimedia and other custom data within Facebook applications.

The book covers how to send notifications and invitations from within an application, update a user's profile, create application control panels for users, and much more.

Table of Contents

  1. Learning Facebook Application Development
  2. Credits
  3. About the Authors
  4. About the Reviewers
  5. Preface
    1. What This Book Covers
    2. Conventions
    3. Reader Feedback
    4. Customer Support
      1. Downloading the Example Code for the Book
      2. Errata
      3. Questions
  6. 1. Getting to Grips with the Facebook Platform
    1. The Purpose of the Facebook Platform
      1. The Standard Web Application Model
      2. The Facebook Web Application Model
    2. The Facebook Platform Elements
      1. The Facebook API
        1. The Facebook API Test Console
      2. FBML
        1. The FBML Test Console
      3. FQL
    3. Obtaining the Facebook Client Libraries
    4. Adding the Developer Application
    5. Setting Up Your Application
      1. Required Fields
      2. Optional Fields
        1. Base Options
        2. Installation Options
        3. Integration Points
    6. Summary
  7. 2. Building a Facebook Application
    1. A Simple Facebook Application
      1. Getting the Server Ready for Action
      2. Creating Your First Facebook Application
        1. The Application Initiation Code
        2. The Application Code
        3. Viewing the New Application
    2. Developing the Simple Application
      1. Examining Variables
      2. Using FQL in Your Application
    3. Writing to the Facebook Profile
      1. Updating the Facebook Cache
    4. Mock AJAX and Your Facebook Profile
      1. Using a Form on Your Profile
      2. Creating a Dynamic Combo-Box
      3. Limiting Access to the Form
    5. Storing Data—Keeping Files on Your Server
      1. Storing FBML on Your Server
      2. Storing Data on Your Server
    6. Summary
  8. 3. Databases, Dashboards, and the Profile
    1. Setting up the Database
      1. Setting the Root Password
      2. Creating the Database
      3. Adding a User
      4. A Table for Our Data
      5. Migrating Data
    2. Accessing the Database from Your Facebook Application
      1. Connecting to the Database
        1. Using a Remote Database
      2. Running Queries on the Database
        1. Obtaining Data from the Database
        2. Inserting Data into the Database
        3. Deleting Data from the Database
      3. Analyzing the Database
        1. Calculating the Number Items in a Table
        2. Grouping and Ordering Data
    3. Updating Everyone's Profile
      1. Updating the Facebook Cache—Remotely
        1. Obtaining the Application Session ID
        2. Using the Session ID to Write to a Profile
      2. Updating More Than One User's Profile
      3. Automating the Facebook Cache Update
        1. A Simple Batch File
        2. Using At Command to Control the Batch File
        3. Using Cron to Control the Batch File
        4. Pros and Cons of the Methods
    4. Tracking Users
      1. A Table for Your Users
      2. Finding Your Application ID
      3. Adding New Users
      4. Removing a User
        1. Defining a Post-Remove URL
      5. Producing a List of Users
    5. The Facebook Dashboard
      1. Adding a Dashboard
        1. Adding Help to the Dashboard
        2. Adding an Action to the Dashboard
        3. The Dashboard Create Button
    6. Facebook JavaScript
      1. The Facebook Contextual Dialog
    7. Summary
  9. 4. Cooking User Data
    1. How to Fetch User Data
      1. FBML
        1. fb:name
        2. fb:pronoun
        3. fb:profile-pic
        4. fb:user
      2. Logical Tags
        1. fb:is-in-network
        2. fb:if-can-see
        3. fb:if-can-see-photo
        4. fb: if-is-friends-with-viewer
        5. fb:is-if-group-member
        6. fb:is-own-profile
        7. fb:if-is-user
        8. fb:if-user-has-added-app
        9. fb:if-is-app-user
    2. FQL
      1. Let's Have a Look at the Schema
      2. JOIN as Sub Query
      3. Effective Searching with Structures
      4. Common Snippets
        1. Find All the friends of a User
        2. Find All Friends Who Have the Current Application Installed
        3. Find All Friends Whose Birthday Is Tomorrow
        4. Find Which Groups a Specific User Is Subscribed To
        5. Find All the Photos Uploaded by the User and in Any Album
      5. Functions You can Use in FQL
    3. Using Facebook API to Retrieve Information
      1. Retrieving Profile Information
      2. Retrieving List of Friends
      3. Finding Out If Some Users are Friends
      4. Retrieving Group Member's Information
      5. Retrieving a User's Photo
    4. Facebook Developers Tool
    5. Summary
  10. 5. FBJS—The JavaScript
    1. How FBJS Works
      1. DOM Manipulation Using FBJS
      2. DRY Means Don't Repeat Yourself
      3. Managing Stylesheet with FBJS
      4. Creating a Drop-Down Menu in FBJS
    2. Dialog
      1. Displaying Information
      2. Accepting User Input
      3. Contextual or Pop Up?
      4. Advanced Input System Using Dialogs
    3. Events
    4. AJAX
      1. Common Tasks
        1. Posting Parameters to Server Side Code
        2. Posting Multibyte Characters
        3. Canceling an AJAX Request
        4. Making Sure that Users have to Log In for the AJAX Request
    5. Summary
  11. 6. Feeds
    1. What Are Feeds?
    2. How to Publish Feeds
    3. Sample Application to Play with Feeds
      1. So How Did it Work?
    4. Publishing News Feed
    5. Difference between These Two Methods
    6. feed_publishTemplatizedAction
    7. Summary
  12. 7. Invitations and Notifications
    1. Invitations
      1. fb:request-form
      2. fb:req-choice
      3. fb:request-form-submit
      4. fb:multi-friend-selector
      5. fb:multi-friend-input
      6. fb:application-name
    2. Notifications
      1. notifications_send
      2. notifications_sendEmail
    3. Tips for Effective Notification and Emailing
    4. Summary
  13. 8. Photos
    1. Photo API
      1. photos_getAlbum
      2. Accessing from an External Application
      3. Uploading Photo
        1. Tagging Your Photos
    2. Slideshow Application
    3. Summary
  14. 9. Tools and Multimedia
    1. Creating a Discussion Board
    2. Taking Comments from Users
    3. Making a Wall Using fb:wall
    4. Increasing Usability Using fb:switch
    5. Using fb:random to Display a Random Option
    6. Increasing Usability Using fb:switch
    7. Sharing Content
      1. Audio Sharing
      2. Video Sharing
    8. Multimedia Contents
      1. Displaying Photo
      2. Managing Audio
      3. Managing Video (FLV Format)
    9. Summary