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

Preface

Facebook is big, by all meanings of the word. It's used by half a billion people—and countless businesses, bands, and public figures—for socializing and self-promotion. It's also a huge development platform, with tens of thousands of applications.

It's now common to see a Facebook "Like" button on blog posts, news articles, and many other websites. In the same way, Facebook integration is becoming more and more desirable for browser-based RIAs and games, with some, like FarmVille, even being based entirely around Facebook. That's where Flash comes in.

What this book covers

Chapter 1, Introduction, gets you up to speed with Facebook and ready to learn to develop Flash applications that connect with the Facebook platform. You'll learn why it's worth putting more time into developing for Facebook than other social networks (and why it's likely to stay that way), and get yourself technically set up for coding.

Chapter 2, Welcome to the Graph, introduces you to Facebook's model for connecting all the information in its huge data stores—the Graph API. You'll discover how intuitive this model is, and will start to explore the publicly available data using AS3 through utility code, which you'll build from scratch.

Chapter 3, Let Me In!, breaks down Facebook's systems for security, permissions, and authentication. You'll learn how to access the private data of Facebook users (including their photos, biographical information, and lists of friends). You will also start using the official Adobe ActionScript 3 SDK for Facebook platform alongside your own utility code.

Chapter 4, Digging Deeper into the Graph, helps you understand the concepts of paging and filtering, so that you aren't restricted to using only the default dataset that Facebook presents you with. You'll find out how to obtain data from specified dates, and how to speed up your applications by retrieving information from multiple sources at once.

Chapter 5, Search Me, builds on the previous chapter by teaching you how to search for data based on criteria other than dates. You'll learn how to retrieve Wall Posts by specific users, pages with specific names, and places by specific geographical coordinates.

Chapter 6, Adding to the Graph, takes you beyond merely retrieving data and into publishing new data to Facebook. You'll find out how to create new Wall Posts (including rich posts including images and embedded hyperlinks); how to comment on other users' Wall Posts; how to create new events, notes, and albums; and how to upload photos from your hard drive.

Chapter 7, FQL Matters, takes a break from the Graph API to teach you how to learn a powerful search tool—Facebook Query Language. You'll trade the Graph API's intuitiveness and simplicity for FQL's depth and additional features, while also understanding the benefits that each approach offers over the other.

Chapter 8, Finishing Off, wraps up what you've learned throughout the book and gets you ready to release your application to the wild. You'll find out how to embed your application into the Facebook website itself; how to get it into the official Facebook Application Directory; and how to export it as a desktop or Android application, while still keeping its Facebook connectivity. Finally, you'll learn how to keep up-to-date with the ever-changing Facebook platform, and discover some useful resources for taking what you've learned even further.

Appendix, Pop Quiz Answers, contains answers to all the Pop Quizzes in the book

What you need for this book

To develop and compile the example code in this book, you will need an AS3 compiler. Sample projects are provided for use with Flash Professional (CS3 and above), Flash Builder, and the free FlashDevelop IDE (with the Flex SDK); if you use a different workflow you will be able to convert these to fit your tools.

You'll also need previous experience with AS3 class-based coding and a Facebook account. The exact requirements here, along with what to do if you don't meet them, are detailed in Chapter 1.

Who this book is for

If you are an AS3 developer who wants to create applications and games that integrate with Facebook—either on the Facebook website itself or off it, then this book is for you. Even if you have no previous experience with Facebook, databases, or server-side programming, you can follow this book.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "All we have to do is pass it an argument of type graph.GraphObject."

A block of code is set as follows:

  for (var key:String in decodedJSON)
  {
     graphObject[key] = decodedJSON[key];
  }

When I wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

if (decodedJSON.data)
{
  //has a "data" property so we assume it is a Graph List
  var graphList:GraphList = new GraphList();
}

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Compile and run your SWF, then expand the Connections box and click on posts".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Tip

Downloading the example code for this book

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.