Book Image

Facebook Graph API Development with Flash

By : Michael James Williams
Book Image

Facebook Graph API Development with Flash

By: Michael James Williams

Overview of this book

The Facebook platform provides you with an ideal solution for building rich, social experiences on the web to develop an effective user experience application. Combined with Flash which effectively enables social interactions, you can create a fully functional application on Facebook. If you've been waiting to get started with your own applications and games on Facebook, with this book you don't have to wait any longer.This book takes you through everything you need to know to integrate your AS3 apps and games with Facebook accompanied by illustrative screenshots and short quizzes.It presents you with in depth coverage of the key underlying concepts such as creating a basic application that runs inside Facebook and exploring the Graph API which greatly simplifies how developers can retrieve data. This book also covers topics on security, permissions and authentication features on Facebook.This beginner's guide starts off by teaching you about retrieving simple public data and then rapidly working your way up to authenticating users, building powerful searches across the entire database, and uploading photos and other content. Throughout the book, you'll learn by building two fundamental components: an RIA Facebook interface and an AS3 SDK that you can drop into any project to add Facebook integration. This easy-to-understand guide has everything written as AS3-only projects with publicly available components, so you can follow along whether you use Flash Pro, Flex, or MXMLC – as long as you know AS3! This hands-on tutorial will present you with a whole new perspective of the three core aspects of Facebook – searching, retrieving, and updating the data .This practical book focuses on how to set up an application on Facebook and how to deal with different contexts like AIR.By the end of this book, you will be confident enough to set up your own application and create social interactions for users to share on Facebook.
Table of Contents (17 chapters)
Facebook Graph API Development with Flash Beginner's Guide
Credits
About the Author
Acknowledgement
About the Reviewer
www.PacktPub.com
Preface
Index

Time for action – an easier way


FQL's WHERE clause doesn't have to use an equals sign. We can use less than, more than, greater than or equal to, and so on — but more interestingly we can use an operator called IN.

  1. Its working is shown in the following code:

    SELECT name
    FROM user
    WHERE uid IN ('123', '456', '789')
  2. That query will get the names of the three users with IDs of 123, 456, and 789. Since a query is just a string, we can construct one from a list of User IDs as shown in the following lines of code:

    var query:String = "SELECT name FROM user WHERE uid IN ("
    for each (varuid:String in jsonListOfFriendIDs);
    {
      query += "'" + uid + "',";
    }
    query = query.substring(0, query.length - 1) + ")";  //replace last comma with a closing parenthesis
    callFQL(query);    //function that calls the API url with this query

What just happened?

This code gets us the same information as before, but only requires two API calls, which is a pretty big improvement. If only we could get it down to one...