Facebook Graph API Development with Flash
()
About this ebook
Related to Facebook Graph API Development with Flash
Related ebooks
Appcelerator Titanium Application Development by Example Beginner's Guide Rating: 0 out of 5 stars0 ratingsLiferay Beginner’s Guide Rating: 4 out of 5 stars4/5LiveCode Mobile Development: Beginner's Guide - Second Edition Rating: 4 out of 5 stars4/5LiveCode Mobile Development Beginner's Guide Rating: 0 out of 5 stars0 ratingsVaadin 7 UI Design By Example: Beginners Guide Rating: 0 out of 5 stars0 ratingsiAd Production Beginner’s Guide Rating: 0 out of 5 stars0 ratingsconcrete5 Beginner's Guide Rating: 0 out of 5 stars0 ratingsRhomobile Beginner's Guide Rating: 0 out of 5 stars0 ratingsMooTools 1.2 Beginner's Guide Rating: 0 out of 5 stars0 ratingsHTML5 Web Application Development By Example Beginner's guide Rating: 0 out of 5 stars0 ratingsWordPress Plugin Development: Beginner's Guide Rating: 0 out of 5 stars0 ratingsGeoServer Beginner's Guide Rating: 0 out of 5 stars0 ratingsCryENGINE 3 Game Development Beginner's Guide Rating: 0 out of 5 stars0 ratingsPhoneGap: Beginner's Guide - Third Edition Rating: 0 out of 5 stars0 ratingsPHP and MongoDB Web Development Beginner’s Guide Rating: 0 out of 5 stars0 ratingsWordPress Mobile Web Development: Beginner's Guide Rating: 0 out of 5 stars0 ratingsSphinx Search Beginner's Guide Rating: 4 out of 5 stars4/5concrete5 Beginner's Guide - Second Edition Rating: 0 out of 5 stars0 ratingsWordPress MU 2.8 - Beginner's Guide Rating: 0 out of 5 stars0 ratingsOracle ADF 11gR2 Development Beginner's Guide Rating: 0 out of 5 stars0 ratingsFlash Facebook Cookbook Rating: 0 out of 5 stars0 ratingsCouchDB and PHP Web Development Beginner’s Guide Rating: 0 out of 5 stars0 ratingsInkscape Beginner’s Guide Rating: 5 out of 5 stars5/5Spring MVC Beginner’s Guide Rating: 2 out of 5 stars2/5Spring MVC: Beginner's Guide - Second Edition Rating: 0 out of 5 stars0 ratingsOUYA Game Development by Example Rating: 0 out of 5 stars0 ratingsCMS Made Simple 1.6 Beginner's Guide Rating: 5 out of 5 stars5/5Eclipse Plug-in Development: Beginner's Guide - Second Edition Rating: 0 out of 5 stars0 ratingsMahara 1.2 ePortfolios Beginner's Guide Rating: 4 out of 5 stars4/5Microsoft Office Live Small Business: Beginner’s Guide Rating: 0 out of 5 stars0 ratings
Information Technology For You
Health Informatics: Practical Guide Rating: 0 out of 5 stars0 ratingsAWS Certified Cloud Practitioner: Study Guide with Practice Questions and Labs Rating: 5 out of 5 stars5/5Data Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5Data Governance For Dummies Rating: 0 out of 5 stars0 ratingsCreating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5Inkscape Beginner’s Guide Rating: 5 out of 5 stars5/5Computer Science: A Concise Introduction Rating: 4 out of 5 stars4/5ChatGPT: The Future of Intelligent Conversation Rating: 4 out of 5 stars4/5The Basics of Hacking and Penetration Testing: Ethical Hacking and Penetration Testing Made Easy Rating: 4 out of 5 stars4/5SharePoint Designer Tutorial: Working with SharePoint Websites Rating: 1 out of 5 stars1/5Panda3d 1.7 Game Developer's Cookbook Rating: 0 out of 5 stars0 ratingsIntroduction to Business Analysis Rating: 0 out of 5 stars0 ratingsHow to Write Effective Emails at Work Rating: 4 out of 5 stars4/5COMPUTER SCIENCE FOR ROOKIES Rating: 0 out of 5 stars0 ratingsCompTIA ITF+ CertMike: Prepare. Practice. Pass the Test! Get Certified!: Exam FC0-U61 Rating: 0 out of 5 stars0 ratingsPractical Ethical Hacking from Scratch Rating: 5 out of 5 stars5/5How To Use Chatgpt: Using Chatgpt To Make Money Online Has Never Been This Simple Rating: 0 out of 5 stars0 ratingsGoogle SketchUp for Game Design: Beginner's Guide Rating: 5 out of 5 stars5/5Codeless Data Structures and Algorithms: Learn DSA Without Writing a Single Line of Code Rating: 0 out of 5 stars0 ratingsHandbook of Digital Forensics and Investigation Rating: 4 out of 5 stars4/5An Ultimate Guide to Kali Linux for Beginners Rating: 3 out of 5 stars3/5Google Cloud Platform an Architect's Guide Rating: 5 out of 5 stars5/5Windows Registry Forensics: Advanced Digital Forensic Analysis of the Windows Registry Rating: 4 out of 5 stars4/5Linux Command Line and Shell Scripting Bible Rating: 3 out of 5 stars3/5Supercommunicator: Explaining the Complicated So Anyone Can Understand Rating: 3 out of 5 stars3/5CompTIA Network+ CertMike: Prepare. Practice. Pass the Test! Get Certified!: Exam N10-008 Rating: 0 out of 5 stars0 ratingsComputer Organization and Design: The Hardware / Software Interface Rating: 4 out of 5 stars4/5
Reviews for Facebook Graph API Development with Flash
0 ratings0 reviews
Book preview
Facebook Graph API Development with Flash - Michael James Williams
Table of Contents
Facebook Graph API Development with Flash Beginner's Guide
Credits
About the Author
Acknowledgement
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. Introduction
What's so great about Facebook?
It's popular
Numbers
It's everywhere
It's interesting to develop for
Have a go hero – get on Facebook
Web hosts
What's a web host?
Why do you need one?
How do you choose one?
Useful software
What about domain names?
Have a go hero – get a web host, upload to it, test
How much AS3 knowledge is required?
The source code
Powered by…
Debugging
Watch out for caching
A final note…
2. Welcome to the Graph
Accessing the Graph API through a Browser
Time for action – loading a Page
What just happened?
Have a go hero – exploring other objects
Accessing the Graph API through AS3
Time for action – retrieving a Page's information in AS3
What just happened?
Time for action – deserializing a JSON object
What just happened?
Time for action – visualizing the info
What just happened?
Understanding connections
Time for action – finding connections in a browser
What just happened?
Have a go hero – exploring connections
Rendering Lists
Time for action – rendering Lists of Posts
What just happened?
Rendering connections
Time for action – displaying a Graph Object's connections
What just happened?
Introducing the Requestor
Time for action – creating an HTTP Requestor
What just happened?
Understanding Connections of Connections
Time for action – loading photos from an album
What just happened?
Putting it all together
Time for action – traversing the Graph
What just happened?
Have a go hero – exploring other areas
Pop Quiz
Summary
3. Let Me In!
What can you see?
Time for action – snooping through other people's accounts
What just happened?
Have a go hero – viewing your privacy settings
What's that got to do with the Graph API?
Access tokens are proof of authorization
User/Application authorization
Time for action – registering an application with Facebook
What just happened?
Application ID + logged-in user = access token
Time for action – requesting an access token with the browser
Registering a redirect URI with our application
Using the Access Token
Me, me, me
What just happened?
Keeping secrets
What did Facebook give us?
Authenticating with AS3
Time for action – Using an access token in our Graph visualizer
That's cheating!
Time for action – authenticating through the application
What just happened?
A different approach
Time for action – authenticating via JavaScript
Creating a callback web page
Receiving the access token
What just happened?
What about users who haven't used the application before?
Have a go hero – dealing with the undecided
Extended permissions
Time for action – obtaining extended permissions
What just happened?
Time for action – requesting extended permissions
Have a go hero – using a permanent access token
I want it all, and I want it now
Have a go hero – dealing with extended permissions
Using the Adobe ActionScript 3 SDK for Facebook platform
Time for action –implementing the SDK
What just happened?
Have a go hero – requesting extended permissions with the SDK
Pop Quiz
Summary
4. Digging Deeper into the Graph
Getting more results with paging
Time for action – displaying the number of objects in a list
What just happened?
Time for action – requesting more Objects
What just happened?
Time for action – requesting more Objects at once
What just happened?
Paging
Time for action – obtaining data in pages
What just happened?
Have a go hero – using limit and offset for other connections
Time for action – adding limit and offset to GraphRequest instances
What just happened?
Date-Based filtering
Time for action – requesting data based on date
What just happened?
Time for action – adding since and until to GraphRequest instances
What just happened?
Time for action – filtering by date using the UI
What just happened?
We gon' partition like it's yo' birthday
Have a go hero – loading birthday wall posts
Date-based paging
Requesting multiple IDs at once
Time for action – using the ids parameter in a Graph URL
What just happened?
Have a go hero – creating a Compound Object based on results from a List
Summary
Pop Quiz
5. Search Me
Using the website's Search box
Time for action – examining quick search results
What just happened?
Time for action – Using the Full Search results
What just happened?
Searching with a Graph URL
Time for action – searching without authorization
What just happened?
Time for action – searching while authorized
What just happened?
Differences
Restrictions
Time for action – implementing a Search window in the Visualizer
What just happened?
Time for action – searching via the SDK
What just happened?
Have a go hero – setting the locale
Searching feeds and wall posts
Time for action – searching your news feed
What just happened?
Time for action – searching a friend@#U+0027:s Wall Posts
What just happened?
Time for action – searching feeds through the Visualizer
What just happened?
Summary
Pop Quiz
6. Adding to the Graph
Hello, Facebook!
Time for action – posting to the user's feed
Request methods
What's a request method?
Time for action – using the POST method
What just happened?
Time for action – listening for errors
What just happened?
Time for action – granting the required permission
What just happened?
Time for action – posting via the SDK
What just happened?
Going further with Wall Posts
Time for action – publishing rich posts
What just happened?
Have a go hero
Posting to another Wall
Time for action – posting to another Wall using the Visualizer
Actions, privacy, and source
Actions
Time for action – literally
What just happened?
Privacy
Time for action – setting a Post's privacy settings
What just happened?
Source
Deleting Graph Objects
Time for action – deleting a Post
Time for action – deleting Posts using the Visualizer
What just happened?
Publishing other kinds of Graph Object
Comments
Likes
What about liking
other Graph Objects?
Deleting Likes
Notes
Events
Event RSVPs
Albums
Photos
Checkins
What about...?
Sending inbox messages
Creating Pages, Groups, Applications, and Videos
Changing biographical information
Making Friends
Inviting Friends to Events
Pop Quiz
Summary
7. FQL Matters
What is FQL?
Understanding the FQL interface
Models of data
Representations of data
Getting information
Time for action – retrieving info from the Page table
What just happened?
Have a go hero – creating an FQL query builder
What about connections?
Photos, Albums, and their Owners
Have a go hero – getting a user's albums
Primary keys
Crow's feet
Have a go hero – drawing your own crows' feet
Link tables
What just happened?
Time for action – getting a user's friends' names with AS3
What just happened?
Time for action – an easier way
What just happened?
Time for action – getting it down to one API call
What just happened?
Have a go hero – Mutual friends
The Graph as a layer
Have a go hero – recreating existing Graph API calls in FQL
Permissions
Checking existing permissions
Getting more information
Restrictions
Searches must use an indexable field
Does this matter in practice?
Advanced FQL
Operators
Comparison
Logical
Have a go hero – getting a list of your events based on location
Have a go hero – finding gatecrashers
Ordering
Paging
Extra functions
Have a go hero – combining what you've learned
Calling multiple queries at once
Pop Quiz
Summary
8. Finishing Off
Putting it online
On Facebook
IFrame
Time for action – setting up an IFrame application
What just happened?
Page tab
Time for action – adding an application to a Page tab
What just happened?
Off Facebook
Your own website
Flash game portals
As a desktop AIR application
Time for action – authorizing through AIR with HTTP
What just happened?
Time for action – authorizing through AIR with the SDK
What just happened?
As an AIR for Android Application
Time for action – authorizing on Android
What just happened?
Have a go hero – modifying the SDK for Android
Choosing your application's Facebook settings
Getting your application out there
Editing the application's profile page
Have a go hero – creating your application's profile page
Custom tabs
The Facebook Application Directory
Watch out for these policies!
What next?
The Official AS3 Facebook SDK
Other Facebook APIs
JavaScript SDK
Insights API
Facebook Chat API
Internationalization API
Adobe Social service
Related Technologies
PHP
Open Graph Protocol
Real-Time Updates
Brand new and coming soon
Facebook Credits
Test users
The New Messages
Facebook developer resources
Official Facebook resources
Other great websites
Me, me, me
Keeping up with the Zuckerbergs
Dealing with change
Summary
A. Pop Quiz Answers
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Index
Facebook Graph API Development with Flash Beginner's Guide
Facebook Graph API Development with Flash Beginner's Guide
Copyright © 2010 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: December 2010
Production Reference: 1081210
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK
ISBN 978-1-849690-74-4
www.packtpub.com
Cover Image by Asher Wishkerman (<a.wishkerman@mpic.de>)
Credits
Author
Michael James Williams
Reviewer
Emanuele Feronato
Acquisition Editor
David Barnes
Development Editor
Hyacintha D'Souza
Technical Editors
Paramanand Bhat
Namita Sahni
Copy Editor
Laxmi Subramanian
Indexer
Monica Ajmera Mehta
Editorial Team Leader
Aditya Belpathak
Project Team Leader
Lata Basantani
Project Coordinator
Vishal Bodwani
Proofreader
Lynda Sliwoski
Graphics
Geetanjali Sawant
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta
About the Author
Michael James Williams is a technical concept writer and freelance Flash developer. He is the technical editor for the tutorial website Activetuts+, and also runs his own blog about Flash game development.
He currently lives in England, in a nice little town that has both a river and a canal, and has been using Facebook since it was just some site that his American housemate wouldn't stop talking about.
You can follow Michael on Twitter at http://twitter.com/MichaelJW.
His public Facebook profile is available at http://on.fb.me/MichaelJamesWilliams.
Activetuts+ can be found at http://active.tutsplus.com/.
Michael's website is http://michaeljameswilliams.com/.
Acknowledgement
I'd like to thank my Dad, for teaching me how to be technical; my Mum, for teaching me how to write; and my little sister, for not being too jealous that I beat her to being a published author.
I also want to thank Ryan Henson Creighton, for inadvertently introducing me to David Barnes; all the Flash developers that make up the awesome community I'm happy to be a part of, particularly Bram, Ryan, Rasmus, Jeff and Steve, and Daniel; Tom, for letting me use his tutorial as a template for my first (and still most popular!) piece of writing; Ian Yates and the rest of Envato™, for enabling me to keep working and earning a living while writing this book; Keith Peters, for providing the awesome MinimalComponents I used throughout this book; and everyone that's ever commented on anything I've written – I really appreciate that.
Finally, I must express my appreciation for and thanks to David, Vishal, Hyacintha, Paramanand, Priya, Namita, and everyone else at Packt Publishing for all their support, help, and hard work. I know I can be stubborn, but it's been a pleasure to work with you all. In particular, thank you to David, who not only approved this book in the first place, but also gave me a huge amount of guidance in all aspects of writing it. And of course, I have to thank Emanuele, not just for doing the technical review of this book, but also for his blog, which (by a funny turn of events) was one of my key inspirations to start writing about Flash in the first place.
About the Reviewer
Emanuele Feronato has been studying programming languages since the early eighties, with a particular interest in web and game development. He taught online programming for the European Social Fund and now co-owns a web development company in Italy where he also works as a lead programmer. His blog, www.emanueleferonato.com, is one of the most visited blogs about indie programming.
I would like to thank Vishal Bodwani at Packt Publishing for the opportunity to review this book, and my little daughter Kimora for making my life happy.
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read, and search across Packt's entire library of books.
Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
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 <feedback@packtpub.com>, 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