You are previewing Facebook Application Development with Graph API Cookbook.
O'Reilly logo
Facebook Application Development with Graph API Cookbook

Book Description

Over 90 recipes to create your own exciting Facebook applications at an incredibly fast pace with Facebook Graph API

  • Dive headfirst into Facebook application development with the all new Facebook Graph API.

  • Packed with many demonstrations on how to use Facebook PHP and JS SDKs.

  • Step by step examples demonstrating common scenarios and problems encountered during Facebook Application Development.

  • Houses an exquisite collection of ready to use Facebook applications.

  • In Detail

    With a user base of nearly 800 million people, Facebook is the number one social networking platform. Applications can be created to interact with this huge user base in various ways both inside and outside Facebook. These applications, if developed effectively and efficiently, offer a free medium for promotion and publicity of a product or an organization.

    Facebook Application Development with Graph API Cookbook covers both the concepts and implementations necessary to develop Facebook applications and provides ready to use code for common scenarios faced by a developer while creating these applications. It incorporates the newly launched Facebook Graph API and also presents the reader with some intuitive ready to use applications.

    This book guides the reader step by step, from start to finish, through various stages of Facebook application development. It begins by exploring the Facebook application registration and discussing the verification and authentication technique. It then takes you through the various ways in which you can use Facebook Graph API for interacting with users such as posting on a user’s wall, tagging a user in a picture, etc. Accessing complex Facebook user data by formulating a series of queries, doing client side scripting and incorporating Facebook Dialog interface are some other features that have been incorporated in this book. Integration of various Facebook Social Plugins such as the like box in your web page has also been discussed. Further you will get to know the concept of virtual currency and how to programmatically derive Facebook analytics data. As the book progresses, you will learn to use and integrate many more advanced features in Facebook application development. The book contains ready to use code that can be deployed instantly. Towards the end, the book houses a variety of ready to use Facebook applications so as to help readers derive their own applications from them.

    Table of Contents

    1. Facebook Application Development with Graph API Cookbook
      1. Table of Contents
      2. Facebook Application Development with Graph API Cookbook
      3. Credits
      4. About the Authors
      5. About the Reviewer
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Creating a New Facebook Application
        1. Introduction
          1. The social network
          2. What makes Facebook tick?
          3. What's in it for the developers?
        2. Downloading PHP-SDK and setting upyour environment
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Registering a new Facebook application
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Secure connection
            2. Sandbox mode
            3. Resetting an application's secret key
        4. Configuring a Facebook application
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Getting authorization and a valid session for the user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Requesting specific permissions from the user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        7. Logging out a user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        8. Handling navigation in an iFrame Facebook application
          1. Getting ready
          2. How to do it...
          3. How it works...
        9. Handling form submission in an iFrame Facebook application
          1. Getting ready
          2. How to do it...
          3. How it works...
        10. Dynamically resizing an iFrame Facebook application
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Parameters
        11. Determining whether a Facebook page has been liked by a user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Customizing an application's tab content based on Facebook page
      9. 2. Be a part of Social Graph
        1. Introduction
          1. Facebook Graph API
          2. Prerequisites for this chapter
        2. Retrieving a user's information
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Liking a post
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Deleting a like
        4. Commenting on a given post
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Deleting a comment
        5. Setting status message
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Deleting a picture, post, or comment of a user
          1. Getting ready
          2. How to do it...
          3. How it works...
        7. Retrieving the current user's friendlist
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Getting a friendlist's members
            2. Creating a new friendlist
            3. Adding a new member to a friendlist
            4. Deleting a friendlist
        8. Creating a post on the wall of a user's friend
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        9. Posting a picture to a specific album of the user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        10. Retrieving the names of the user's friends who have liked a particular status message
          1. Getting ready
          2. How to do it...
          3. How it works...
        11. Creating an event
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Deleting an event
        12. Paging through a user's friends
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        13. Searching through a user's feed
          1. Getting ready
          2. How to do it...
          3. How it works...
        14. Tagging users in a picture
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        15. Adding a subscription for real time updates related to a user object
          1. Getting ready
          2. How to do it...
          3. How it works...
        16. Creating a callback for handling real time updates
          1. Getting ready
          2. How to do it...
          3. How it works...
        17. Deleting subscriptions
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      10. 3. Querying Facebook
        1. Introduction
          1. Prerequisites
        2. Returning information about a user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Getting the status messages of a user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Retrieving profile pictures of a user's friends
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Getting the links posted by a user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Getting the Facebook pages followed by a user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        7. Determining if two users are friends
          1. Getting ready
          2. How to do it...
          3. How it works...
        8. Retrieving information of a group
          1. Getting ready
          2. How to do it...
          3. How it works...
        9. Retrieving members of a group
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        10. Retrieving friends from a specific friend list
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        11. Getting all the messages in a thread
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        12. Checking the status of permissions for an application
          1. Getting ready
          2. How to do it...
          3. How it works...
        13. Getting notifications, and their senders, for the current user
          1. Getting ready
          2. How to do it...
          3. How it works...
        14. Retrieving video details associated with a user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        15. Getting the five latest photos in which a user has been tagged
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        16. Retrieving the latest photos published by a user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        17. Retrieving details of an event
          1. Getting ready
          2. How to do it...
          3. How it works...
        18. Retrieving details of a user's friends by using the multiquery method
          1. Getting ready
          2. How to do it...
          3. How it works...
      11. 4. Using FB Script
        1. Introduction
          1. Prerequisites
        2. Getting the current user status and performing session validation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Setting up extended permissions during login
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Logging out a user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Resetting the size of iframe
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Making a Graph API call
          1. Getting ready
          2. How to do it...
          3. How it works...
        7. Executing an FQL query
          1. Getting ready
          2. How to do it...
          3. How it works...
        8. Subscribing to an event change
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        9. Unsubscribing to an event change
          1. Getting ready
          2. How to do it...
          3. How it works...
        10. Retrieving a profile picture using XFBML
          1. Getting ready
          2. How to do it...
          3. How it works...
        11. Adding bookmarks using XFBML
          1. Getting ready
          2. How to do it...
          3. How it works...
        12. Authentication and setting up extended permissions using XFBML
          1. Getting ready
          2. How to do it...
          3. How it works...
      12. 5. Expressing Yourself
        1. Introduction
          1. Prerequisites
        2. Prompting the user to publish a story
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Using Dialog to add someone as a friend
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Using the OAuth Dialog to request permissions for your application
          1. Getting ready
          2. How to do it...
          3. How it works...
        5. Prompting the user to send a request to friends
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Processing requests sent to the user by friends
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
      13. 6. Bringing Facebook to your Website
        1. Introduction
        2. Setting up the Like button on your web page
          1. How to do it...
          2. How it works...
          3. There's more...
        3. Adding a Like box
          1. How to do it...
          2. How it works...
          3. There's more...
        4. Setting up the Activity Feed plugin
          1. How to do it...
          2. How it works...
          3. There's more...
        5. Setting up the Facepile plugin on your web page
          1. How to do it...
          2. How it works...
        6. Integrating the Live Stream plugin using XFBML
          1. Getting ready
          2. How to do it...
          3. How it works...
        7. Integrating the Comment box using XFBML
          1. Getting ready
          2. How to do it...
          3. How it works...
        8. Integrating the Send button using XFBML
          1. Getting ready
          2. How to do it...
            1. Integrating the Send button with the Like button
            2. Integrating a stand-alone Send button
          3. How it works...
        9. Login with Faces
          1. Getting ready
          2. How to do it...
          3. How it works...
      14. 7. Connecting Websites to the Social Graph
        1. Introduction
        2. Integrating web pages into the social graph
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Defining location information
            2. Defining contact information
            3. Defining a custom object type
          4. See also
        3. Integrating audio and video data
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Attaching the video to the social graph
          5. See also
        4. Administering your page
          1. How to do it...
          2. How it works...
          3. There's more...
        5. Publishing stream updates to the users
          1. How to do it...
          2. How it works...
      15. 8. Fiddling with Virtual Currency
        1. Introduction
        2. Setting up the application for Facebook Credits
          1. How to do it...
          2. How it works...
          3. See also
        3. Setting up an application callback for Facebook Credits
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Creating Facebook Credits frontend using JavaScript SDK
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Getting credits without purchase
        5. Getting the order details
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Implementing custom offers
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Integrating DealSpot
        7. Refunding the order
          1. Getting ready
          2. How to do it...
          3. How it works...
        8. Developing a "Send a Gift" application and integrating with Facebook Credits
          1. Getting ready
          2. How to do it...
          3. How it works...
      16. 9. Creating Advertisements and Analyzing Metric Data
        1. Introduction
          1. Prerequisites
        2. Retrieving impressions of the Like Box plugin
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Using the Google Chart API to create a chart for a given metric
        3. Retrieving a page's stream views and wall posts using batch request
          1. Getting ready
          2. How to do it...
          3. How it works...
        4. Getting the number of installations of an application using FQL
          1. Getting ready
          2. How to do it...
          3. How it works...
        5. Getting statistics about visitors using FQL multiquery
          1. Getting ready
          2. How to do it...
          3. How it works...
        6. Creating a new ad for your Facebook application
          1. How to do it...
          2. How it works...
      17. 10. Creating Instant Applications
        1. Introduction
          1. Getting ready
        2. Creating a "Your Good Luck Charm of the Day" Facebook application
          1. Getting ready
          2. How to do it...
          3. How it works...
        3. Designing a "My Fast Friends" Facebook application
          1. Getting ready
          2. How to do it...
          3. How it works...
        4. Setting up a photo collage
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Building a birthday calendar
          1. Getting ready
          2. How to do it...
          3. How it works...
        6. Developing an application to classify friends according to the cities they live in
          1. Getting ready
          2. How to do it...
          3. How it works...
      18. 11. Using Facebook Open Graph Beta
        1. Introduction
        2. Setting up your application for using Facebook Open Graph Beta
          1. How to do it...
          2. How it works...
          3. See also
        3. Defining actions, objects, and aggregations for your application
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. See also
        4. Customizing the Facebook Auth Dialog box
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Requesting permission for publishing to the user's timeline
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Defining your web page as a Facebook graph object
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Publishing actions of a user to Facebook
          1. Getting ready
          2. How to do it...
          3. How it works...
      19. Index