My New Book on Flash Facebook Development

by Michael James Williams on January 10, 2011 · 54 comments

in Articles

I wrote a book!

Flash Facebook Development book

Early last year, I signed a book deal with Packt Publishing. I spent most of 2010 working on it, and it’s finally finished, published, and on the shelves.

The book is a beginner’s guide to creating Flash Facebook applications and games. That includes apps like Graffiti and games FarmVille, which are designed to be played entirely within Facebook, as well Flash projects hosted outside Facebook that tap in to the user’s Facebook profile and friends list to give a more personalised experience.

Who is it aimed at?

When I say ‘beginner’s guide’, I mean that you don’t have to know anything about Facebook integration or server-side scripting or SQL in order to start. You’ll need a basic understanding of Flash and AS3, but no more complex than you could pick up from my avoider game tutorial.

So the book is aimed at you, if you know how to build Flash projects and are interested in hooking them up to that huge social network.

What does it cover?

Okay, okay, maybe I shouldn’t have mentioned FarmVille up there. This book isn’t going to walk you through building a FarmVille clone. If it did, it couldn’t be very helpful; it would have to cover game design, and animation, and a whole bunch of other topics that have nothing to do with Facebook.

Instead, it’s all about Facebook integration. I’ve made sure to explain all the AS3 classes and libraries that some readers may not be familiar with, but apart from that, the book has a single focus.

At the start of the book, you’re given source files, containing the user interface code for a Flash project called Visualizer. This is an app which lets the user explore all the information available on Facebook — including their profile information, their photos, their friends list, their friends photos, and more — but it’s missing all of the code required to hook it up to Facebook.

As you work through the book, you’ll write that code yourself, learning how it all works without having to worry about designing or developing the user interface. (Again: a single focus.) After building each new feature from scratch, you’ll learn how to integrate the same feature using the official Adobe Facebook SDK; this way, when you work on your own projects, you’ll have the freedom to design your own solution, and the knowledge to use the standard one.

Each chapter is roughly twice the length of one of my longer tutorials (like most of the parts of the avoider game tutorial), and they’re designed to be worked through in sequence. Let me break down what each is about:

  1. Introduction explains why you should care about Facebook, what you’re going to do in the book, how to get setup, what you need to know before continuing, and what to do if you don’t already have that knowledge.
  2. Welcome to the Graph introduces the Graph API, Facebook’s model for connecting all of the information that it stores. By the midpoint of this chapter, you’ll already be retrieving data from Facebook.
  3. Let Me In! is where things get really interesting; you’ll learn how to let your user log in to Facebook through your app, allowing you to retrieve their personal data — and that of their friends.
  4. Digging Deeper into the Graph is all about paging and filtering the data you retrieve from Facebook, so you can look into the past. It also introduces you to the most annoying bug on the whole Facebook platform.
  5. Search Me, as you can probably guess, explains how to search for posts and users from specific criteria. By the end of this chapter, your project will have a feature that even the Facebook website itself is missing.
  6. Adding to the Graph is where you go from being a passive observer to an active creator; you discover how to create new wall posts, upload photos, and so on.
  7. FQL Matters is different to all the other chapters; it has nothing to do with the Visualizer. You could skip it, but I recommend that you don’t, because it introduces you to the Facebook Query Language, a powerful tool for extracting data from Facebook.
  8. Finishing Off covers a grab-bag of miscellaneous important topics that didn’t really fit anywhere else. How to embed your project inside the Facebook website; how to use what you’ve learnt when building an AIR (or AIR for Android) application; the problems with portals; and what to learn next.

All that in about 300 pages :)

Won’t it become outdated?

Facebook’s developers move quickly. Really quickly. The Facebook Platform is always shifting and changing. This was my major concern when planning the book; I was worried that all the information in it would be out of date before the ink was dry.

So, rather than giving you a set of instructions and code snippets to copy, I focused on explaining the underlying concepts of Facebook development. Once you’ve read the book, you’ll understand how Facebook works, and you’ll be well-equipped to deal with whatever changes Mark Zuckerberg’s team throws at you.

For example, in Adding to the Graph, I explained how to “like” a wall post, but said that it was impossible to “like” a comment on a wall post through code. This was true when I wrote it, but not any more. So what? If you understand how to “like” a wall post, you’ll be able to apply that knowledge to comments.

A section in Finishing Off explains how to keep up to date with all the improvements made to the platform, so you would be aware that it was now possible to “like” a comment, and could simply add this information to the understanding of the concepts that you’d already built up.

Isn’t all that information available online?

Yeah, there’s a lot of information about Flash Facebook development available online for free. There’s the official documentation, there are tutorial blogs (of course!) and there are forums. I learnt everything I know about Facebook development from these free resources.

But you have to ask yourself whether it’s worth your time. The information is spread across different sites. A lot of what you’ll read on blogs and forums is speculation, like “to do X, you must first do A, B, C, and D” when actually only B is required. Sometimes it’s just plain wrong. The platform has bugs, and sometimes even the information in the official documentation doesn’t do what it claims to.

My book gathers all the correct knowledge from these various sources, and puts them in one place. Then it structures it, using a combination of Packt Publishing’s techniques and my own, in an order that’s designed to help you learn.

In other words: I spent months piecing all of this together. You can bypass all that time (and that frustration, when things just don’t work) for a few dollars. Whether that’s worth it to you depends on how much you value your time. Or how much of a masochist you are, I suppose ;)

Where can I get it?

I’m glad you asked :P Both PDF and paperback versions are available for sale on the Packt Publishing webpage for the book.

You can also buy the book through Amazon, and if you use these links I’ll make a little extra cash on the sale: Amazon USA | Amazon UK. Hooray for affiliate links.

Otherwise, you might be able to find them in your local bookshop, assuming you still have a local bookshop.

Can I read some of it RIGHT NOW?

The second chapter (which is where you start writing some code to actually get data from Facebook) is available for free online.

Click here to read it (PDF format), or right-click here and select “Save link as” to download it for later.

I hope you like it! And if you do get a copy, I’d really appreciate it if you’d post an honest review on Amazon. I’d also love to see what you make with it, so post a link to your creations in the comments below :)

And let me quickly thank the whole of the Packt Publishing team, as well as Emanuele Feronato (who did the technical editing for the book) and Keith Peters (who wrote the awesome Minimal Components that I used for the Visualizer).

Any questions?

Additional Stuff

Rasmus Wriedt Larsen wanted to add functionality that redirected the user to the login page if they weren’t already authorised… so he did! You can see his implementation here. Thanks for sharing it, Rasmus!

{ 54 comments… read them below or add one }

Martin January 10, 2011 at 1:15 pm

Nice. Is it pure as3? Or connecting and login via php?

Michael James Williams January 10, 2011 at 1:18 pm

Totally AS3. You don’t need to know any PHP. There’s some HTML and JS, and it’s helpful to know a bit of those before you start, but I do cover what you need to know.

Tiago Dias January 10, 2011 at 2:58 pm

Nice, I know how hard it is to write a book. :) Congrats to the publishing and I will try to grab one during the next few months, interested in checking it out.

Rasmus Wriedt Larsen January 10, 2011 at 3:46 pm

Hey Michael.

Good to finally see a blog post again ;)

Congratulations on finally finishing the book! Great job.

Hope I win one of those free copis from Activetuts+, because I really want to read it.

Scarybug January 10, 2011 at 4:51 pm

Congratulations! That’s really cool. I can’t imagine how much work it must have been!

Michael James Williams January 11, 2011 at 3:49 am

@Tiago: Haha, I bet you do! Thank you :)

@Rasmus: Yeah it’s been too long. But now that the book’s done I aim to blog more frequently again. Cheers for your kind words and good luck with the contest.

@Scarybug: Thanks man :) It felt like a lot at the time, but less and less so as the days go by…

StimuliTV January 15, 2011 at 5:06 pm

Hi Michael,

Nice work and well done on the book it’s really useful so far.

Unfortunately the demo application (ch6 source code) when run on a server doesn’t seem to work as expected, i mean it works in some situations but it’s a also quite buggy and i guess some of the api calls might have changed, which makes it appear worse by causing unforeseen errors.

I really want to have a proper play with this, so do you have an updated version online that works? msg me if you want to keep it private.

Maybe we could fix it together?

Cheers

Michael James Williams January 15, 2011 at 5:10 pm

Hey StimuliTV, glad you’re finding it useful!

Damn, I’m sorry to hear that. Can you send me an email with the details (use the Contact form) and we’ll sort it out?

My version of the Visualizer is up here and seems to be working okay, using same code from the book.

(For anyone else reading: I’ll post the solution here afterwards.)

Mitch Early January 16, 2011 at 1:56 am

Hi Michael,

I’ve found had some issues from the get go with Chapter 2 in the first example of pulling data from the packtpub facebook page.

I don’t know if you have a specific place in your blog to post this so if you do let me know however I’m getting the below error. The url is fine and there are no security issues… could you please help as I cannot move forward..

Error opening URL ‘https://graph.facebook.com/packtpub’
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: https://graph.facebook.com/packtpub
at controllers::CustomGraphContainerController()
at Main/setUpGCC()
at Main/init()
at Main()

Mitch Early January 16, 2011 at 2:12 am

Michael it turn’s out AVG firewall settings for some reason was blocking flash player from connecting once compiled. Quite strange as all my other applications connect without issues from AVG.

You may remove these posts if you like. Problem solved.
Cheers

Michael James Williams January 18, 2011 at 1:20 pm

Mitch: that’s great news, thanks for posting it here :)

Pedro January 26, 2011 at 12:48 pm

Hi Michael,

I’ve bought your book and i have some problems in chapter 3, just after receiving the access token in the application (about page 98).

I access the url where I host my application. It shows the authentication window and loads/shows the data about my profile with the extended data (metadata=1 and valid access token). But, the problem is that if I try to access the “friends” connection, I get an Error #2032: Stream Error. URL.

This just occurs in IE8. Firefox works correctly and shows the friends list (and other connections).

Searching the internet I’ve found that there is a problem with IE8, flash player, and facebook, but cannot find any solution. Do you know any solution or patch for this problem?. Dont know if you can answer my question here or through email.

Thanks

Michael James Williams January 27, 2011 at 3:54 pm

Note: Pedro and I talked aobuut this issue by email, and he discovered a small error that I made: you need to set the target Flash Player version to FP10 or above. In my Flash Professional source FLAs, I had it set to FP9. (Oops.)

This presents a problem if you use Flash Pro CS3, as CS3 can’t target FP10. I’m afraid the solution is either to upgrade to a newer version of Flash Pro, or to use something totally different. I’ve written a guide to FlashDevelop, my editor of choice, here. FlashDevelop is totally free and will let you target any version of Flash Player.

Steven February 2, 2011 at 3:22 pm

Just ordered the book :)

Drew February 11, 2011 at 3:00 pm

Hi Michael. I’m reading your book right now and finding it very useful. I’ve found an issue that I can’t seem to find any reference to in the book though.

I want to load the cover photos of a facebook users albums into flash. I can grab the album names, aid & cover_pid with the fql query:
var fql:String = “SELECT name, aid, cover_pid FROM album WHERE owner = me()”;

That works fine.

However, I *cannot” use the cover_pid to load the cover photo of album! If I use
Facebook.getImageUrl(childObject.cover_pid);
I get something along the lines of
https://graph.facebook.com/100001983283318_24440/picture
which is an invalid photo url.
Strangely enough, the first part of the cover_pid seems to be the same for all photo albums. The cover_pid for the next album is:
https://graph.facebook.com/100001983283318_80122/picture

Any idea how to get round this?
Drew

Michael James Williams February 12, 2011 at 1:23 am

Steven: Awesome, thanks so much!

Drew: Interesting bug (and one that I was not aware of). As a quick workaround, I believe it’s possible to get the cover photo of the album via https://graph.facebook.com/«aid»/picture/, though I could be wrong here.

Would I be right in guessing that you own the profile with ID 100001983283318? If so, perhaps facebook is getting the IDs confused. Does https://graph.facebook.com/100001983283318_24440/ return anything for you when using an access token?

Drew February 12, 2011 at 4:19 pm

Hey Michael
Yes, 100001983283318 is my test profile. Accessing https://graph.facebook.com/100001983283318_24440/ returns “false” (just the word “false” in firefox, not a json object).

I’m afraid your suggestion of https://graph.facebook.com/«aid»/picture brings up an exception:
{“error”: {“type”: “Exception”, “message”: “No node specified” }}

I worked round it by storing the “name, aid, cover_pid” from the first query into an array, then looping through the array and making the following query individually for each cover_pid:
“SELECT src_big, pid FROM photo WHERE pid = ‘” + album_cover_pid + “‘”;

Not a great solution, as if the user has 50 photo albums, it will make 50 fql calls.

One other quick question – if you look at any photo album gallery on facebook, all the images have been cropped to fit a landscape preview (which appears to be about 211×157 pixels). Is there a way to access these images from flash? Somehow they have manages to crop all album photos, whether they were landscape or portrait, down to this neat, landscape 211×157 size. My app would look a whole lot better if I could use these cropped images, rather than the various shaped images returned from the “src_big” query.
Cheers
Drew

Frédéric CHAPLIN February 18, 2011 at 6:34 am

Thank you for this book. I purchased it and I’m learning fast.
After some work, all exercise are working.

I have some question, but i don’t want to spam you blog… I sent you an E-mail.

Cheers from France.

Frédéric CHAPLIN February 18, 2011 at 6:49 am

Thank you for this book. I purchased it and I’m learning fast.
After some work, all exercise are working.

I have a question. (Finally, i post it here,so others people may read it… sorry for double posting…)

When you use URLRequest to connect your app to facebook, you MUST give a callback URL, ok.
When you use the SDKRequestor, you give only the app ID to the method. But the callback URL is still necessary somewhere, no ?

How do the sdk knows about wich callback URL it must take ? Does it read the app properties on facebook when connecting ? It seems not as we don’t give app secret ID.
Or does it take the main page of the app (index.html) as the callback url ? How can we change this ?

All is working fine, this just curiosity.
Again, thanks for your book !

Cheers from France,
Fred.

Michael James Williams February 24, 2011 at 10:59 pm

Oh darn it, the notifications from these comments didn’t come through to my inbox, and I missed them :/ Sorry.

Drew: I’m afraid I don’t understand the cause of that problem, and it sounds like it’s just some bug on Facebook’s end. I could be wrong. Your workaround is pretty neat :)

As for your other question, I’m not sure about the 211x157px images, but you can use the icon property to get a thumbnail :)

Frédéric: Thanks for the kind words! Sorry, but I never received your email.

That is a great question. Weird; I can’t find the answer! You can see in sdkindex.html that there’s a function called redirect() which takes the redirect URI as a parameter, but I can’t see where this function is called. It’s not in any of the AS files, HTML files, or JS files. Most peculiar!

I assume, then, that it uses the Post-Authorise Redirect URL that you set in your app’s Facebook Integration Settings. That makes sense, at least.

Netto February 26, 2011 at 6:23 pm

I just bought your book but I’ve annoying issues with the Font. I followed the instruction you mark in the readme file over Flash Professional, I’m using it, I deleted the folder bit101 and the font from library, I’ve loaded the swc file and changed the player publish settings to FP 10 but it doesn’t work so far. It throws the error :

/Users/myhost/Desktop/0744_Code_0/Flash Professional/Chapter2_Start/src/graph/controls/SearchUI.as, Line 12 1017: The definition of base class Window was not found.

Obviously the error is related to the deletion of the folder bit101 that contains the Window.as class file. Any workaround?

Thanks in advance

Michael James Williams February 28, 2011 at 10:07 pm

Hey Netto, which version of Flash Pro do you have?

The Window class should be defined in the SWC file; is it possible that it’s not loaded correctly?

Netto March 1, 2011 at 12:39 pm

Hi Michael

I use Flash Pro CS5. Thanks for the reply! I’m about to work with Flash Builder in order to get your files work for me and study your book, but I used to work, my fault, chiefly with Flash Pro. Anyway often Flash ask me for the conversion of metadata just like the or tag but this time it doesn’t.

Thanks in advance
N.

Joel March 4, 2011 at 9:27 pm

Hi MIchael.

Love your book. I´m in chapter 5 and everything works as expected with the visualizer.

But I´m having trouble when you teach how to “Build an AS3 Facebook SDK that you can drop into any AS3 project to add Facebook integration” (quoting the “What you will learn from this book” : )

how do i separate the visualizer from the facebook integration classe. In other words wich classe i need to import in order to get facebook integration with my project.

thank you in advance.

Leo March 16, 2011 at 5:59 am

Hello! The code bellow from the book causes this error for me and all my class mates: Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: https://graph.facebook.com/PacktPub

The URL: https://graph.facebook.com/PacktPub is valid as we have tested it in the browser and the data are returned.

We use various computer with various settings and various AV, but the issue is consistent across all machine. Before we log on to Amazon and start posting negative review we wanted to give you a chance to address the problem by providing a solution as the book is useless otherwise since this is a blocking issue.

request.url = "https://graph.facebook.com/PacktPub";
loader.addEventListener(Event.COMPLETE, onGraphDataLoadComplete);
loader.load(request);

Michael James Williams March 16, 2011 at 5:54 pm

Whoa, I missed a few emails again. Sorry.

@Netto: Did this work with Flash Builder?

@Joel: You’ll need everything in the “graph” package, and everything that they import (like the “com.adobe” and “com.facebook” packages). To be safe, copy the “com”, “events”, and “graph” folders across to your new project.

@Leo: Sorry to hear this, that must be really frustrating. This code is working for me so I’m not sure what is causing the problem; I’ll need some more information.

Please import flash.events.HTTPStatusEvent to the class file of that code, then modify the code as follows:

request.url = "https://graph.facebook.com/PacktPub";
loader.addEventListener(Event.COMPLETE, onGraphDataLoadComplete);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatusMessage);
loader.load(request);

…then add this function:

public function onHttpStatusMessage(event:HTTPStatusEvent):void
{
    trace(event.status + " -- " + event.toString());
}

Let me know what gets traced, and I’ll see what I can do.

Leo March 18, 2011 at 3:24 am

Hi Michael,

I implemented what you suggested and here is the log you asked for:

[SWF] C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\bin\Main.swf - 197,374 bytes after decompression
0 -- [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=0 responseURL=null]
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: https://graph.facebook.com/PacktPub
    at controllers::CustomGraphContainerController()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\controllers\CustomGraphContainerController.as:14]
    at Main/setUpGCC()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\Main.as:71]
    at Main/init()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\Main.as:34]
    at flash.display::DisplayObjectContainer/addChildAt()
    at flash.display::Stage/addChildAt()
    at Preloader/startup()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\Preloader.as:61]
    at Preloader/loadingFinished()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\Preloader.as:55]
    at Preloader/checkFrame()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\Preloader.as:43]

Michael James Williams March 21, 2011 at 1:42 am

Thanks for that, Leo. Unfortunately the error code returned is an irritatingly vague one (Flash’s fault, not yours), which doesn’t help to solve the problem. I’ve sent you an email!

Sebastian March 23, 2011 at 4:38 am

Hi Michael
I bought this book from amazon, (received yesterday in paper ).
I can´t find where to download the example files, could you help me?

Thank you.

Michael James Williams March 29, 2011 at 2:18 pm

Hey Sebastian,

Thanks for buying my book! Here’s the link to get the source files: https://www.packtpub.com/support?nid=6669

Lina April 4, 2011 at 2:36 pm

Hello Michael,

At First Thanks Alot for your books :)
I Want to make sure if this book will make me create games in facebook with competitions & scores of friends!
Thanks Alot..

Michael James Williams April 4, 2011 at 5:14 pm

Hey Lina! Yes and no — there’s nothing about actual game development in the book, and in order to save and display the scores of the player’s friends you’ll need to learn about a server-side scripting language like PHP, but for the actual Facebook-related code, yeah, this book will cover you :)

Lina April 4, 2011 at 11:13 pm

Thanks Michael for your reply…Do you know any book or tutorial talking about this topic ! and if you don’t know what i need to make a game with scores & competitions in facbook .Thanks for your effort:)

Michael James Williams April 5, 2011 at 12:17 am

It’s been a while since I was first learning that topic. You could try PHP, it’s pretty common: check out http://net.tutsplus.com/ for some tutorials :)

Lina April 5, 2011 at 12:23 am

Ok Let’s say your book with php i can make a game in facebook.!

Michael James Williams April 5, 2011 at 12:40 am

If you learnt PHP on top of everything in my book, then yeah, you could make games that stored friends’ scores and competition results when playing a Facebook game, yeah :)

sigher April 22, 2011 at 11:25 am

Hello, James
Well, I am a developer in CHINA. Your tutorial is inspiring funny. I used to get involved in AS2 and failed to adapt to AS3. Your examples give me a a good beginning in my AS3 career. I believe you may be interested in this AS2 written game, it’s a half-completed one,however.
download here:http://sites.google.com/site/squarecraft/
I appreciate your unique views as a developer. Hope to see more fabulous games.
It’s great to make a friend.
from Sigher
PS: I hope my English writing is not so confusing.

Michael James Williams April 26, 2011 at 8:44 pm

Hi Sigher,

Thanks for your kind words, and for the link to Squarecraft :)

Good luck with your AS3 career!

Steve June 5, 2011 at 8:47 pm

Micheal,
How can I contact you? I am having major errors trying to get through Chapter 2 but your blog won’t let me post the errors, it says that it looks like spam, which it isn’t. I’ve tried getting your email address on this site but all I find are 404 error pages. Like one of the other users above, I’d like to give you a chance to help me before reviewing your book on Amazon.

Steve June 5, 2011 at 8:51 pm

I am trying to get your first example working but can’t even get by Chapter 2 because of errors. If I put this into a web browser
graph.facebook.com/PacktPub/posts

I get this error OAuthException An access token is required to request this resource.

Your book assumes that everything comes back fine. When I try to move on in the example and try to render the list I get this error:

“Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: http://graph.facebook.com/PacktPub/posts
at controllers::CustomGraphContainerController()[/Users/as2011/Documents/Adobe Flash Builder 4/Chapter2_Start/src/controllers/CustomGraphContainerController.as:19]“

Line 19 of CustomGraphContainerController is this

var loader:URLLoader = new URLLoader()
var req:URLRequest = new URLRequest()
req.url = “http://graph.facebook.com/PacktPub/posts”

When I change req.url to “http://graph.facebook.com/PacktPub” it works fine. I’m assuming that it has something to do with the posts url not returning any data and saying that there’s an OAuthException. Did Facebook change something so that your code no longer works?

Michael James Williams June 5, 2011 at 9:27 pm

Hey Steve,

Yeah, all the pages on my site are broken; I’m working on fixing it. In the mean time, you can reach me at contactmichael [at] michaeljameswilliams dotcom.

The error you’re reporting is thanks to a change Facebook implemented yesterday (literally yesterday) which stops you accessing a Page’s posts without having an access token. Read through the rest of Chapter 2 (without trying to actually do the exercises), then follow Chapter 3 (and do the exercises); after that, go back to Chapter 2 and use what you learned in Chapter 3 to get an access token which will let you access the posts.

Sorry for the hassle! That’s the problem when dealing with a rapidly-developing platform like this ;)

Michael James Williams June 5, 2011 at 9:35 pm

I’ve now requested for this change (and my workaround) to be added to the errata on the Packt website, so other readers will know what to do. Thanks for letting me know about it!

Amos June 25, 2011 at 1:08 am

Hi Micheal,

I am going through the code in the book, and in the end of chapter 3 there is intro to the as3 API. I noticed there are differences between the API code and the current code in the SVN of the facebook-actionscript-api.
Mainly, the FBJSBridge.js is deprecated and a js bridge is embedded inside the API code. This causes some errors in your code with Facebook.init on IE browser.

Is it possible that the code in the book is outdated? if so, do you recommend replacing it with 1.6?

Michael James Williams July 5, 2011 at 10:15 am

Amos and I spoke about this via email. I must admit, I’m stumped. I think it’s an issue with the Adobe API, but I’m not sure what.

Anyway, Amos came up with a solution, and posted it to his blog here: Facebook API Blues. Check it out if you’re having the same problem.

Jeff Mullen August 27, 2011 at 9:05 pm

Thank you for writing this book. Having spent the last three weeks going through the so-called documentation for the facebook API, I can offer my concurrence that it is much needed. I am considering buying this book, but must have a few questions answered before I can determine whether it is appropriate for my needs.

To get myself up and running, I decided to clone a gifting ap. Yes, I know that there is a facebook application that creates gifting aps with no coding involved, but gifting applications are useful as subsystems of facebook games and thus the source code for one is actually far from invaluable. This helps improve an application’s visibility by posting something friendly on a user’s friends’ walls, as I’m sure you already know. The concept is simple: the user selects a picture, then a list of friends to send it to. The application sends the picture to the friends as a wall post and a message. The user may respond to the message to “accept” the gift, an act for which the issuing user and the responding user my reap some reward within the application, because…the application responds to the acceptance, saving a value…somewhere.

I’ve studied the facebook API long enough to know that one should use a dialog to select the friends and send the message, including the picture. What I can’t find is

1) How a request response can be “aimed” at an application rather than another user/how an application would receive this response, and

2) How the application would restore the information. I’ve noticed in the documentation that every application has a “score,” but there is no documentation on how to change this value. Also, no book on facebook would be complete without mention of various methods of persisting data. Facebook, as best I can tell, discourages saving data on their servers. In light of that, it would behoove the author of any good book on designing applications with that API to at least direct the reader to different sources methods of persisting data (facebook if it allows this, setting up a server and/or DBMS (Apache and MySQL are common, but there are others) on your own computer if necessary, memory-resident facilities like SQLite and specialty products like Persistence Manager, which works only on mobile aps, would be worth mentioning.

Does your book do, help with, any of these things?

Michael James Williams August 27, 2011 at 11:14 pm

Hey Jeff,

I’m afraid it does not. I realise this seems like a serious oversight, but I wanted the book to be all about Flash rather than server-side scripting. What you want, I expect, is a book about PHP or ASP.NET and the Graph API — unfortunately, I don’t know of any that I could personally recommend to you.

Jeff Mullen August 30, 2011 at 11:36 pm

Hey, Michael,

I was really impressed with your quick and honest response. It is obvious that you are sincere in your efforts to help your fellow coders, and that your book is an honest effort to help solve a pressing problem.

That makes the rest of this comment harder to write, and I’d like to apologize in advance if any of it seems overly harsh.

I can understand not showing people how to set up an apache server on their home computers. This is beyond the stated purpose of your book. That your book does not cover my 2nd problem is not a knock against it.

There was, however, another problem: your book, according to your comment, does not show people how to use dialogs, how to fashion a request whose response an application can receive, and how an application can respond to that request. This, unfortunately, is well within the book’s purview, and is a necessary part of any facebook ap programmer’s skills.

Without it, the book is incomplete–and I’m sorry that I have to write that.

I’m hoping against hope that you really DID include this in your book, and that you only answered “no” to my 2nd problem. This is also an understandable oversight. I would appreciate it if, should this be the case, you would write another comment and let us all know. It would be enough to make me seriously consider buying the book.

Again, I apologize for this, and I hope your book sells well. Thanks again for your speedy and sincere reply.

Michael James Williams August 31, 2011 at 11:29 pm

Hi Jeff,

Hmm, perhaps I misinterpreted your question. See, Facebook can communicate with an app in two ways. One way is by sending a message to the app at a point when the user is not actively using it — for instance, when a user removes an app from their list of trusted apps, Facebook loads a webpage that you, the developer, specifies, passing it some information so that you can update that user’s info. This requires server-side scripting, naturally, and I have not included anything about it in the book. Since you mentioned server-side scripting I assumed your first question referred to this, but perhaps I was wrong.

The second way of communicating is while the user is actively using an app, and can be handled through AS3 (or JavaScript via ExternalInterface). This basically involves downloading XML or JSON (via a URLLoader to which you pass certain parameters, for instance), which is how the data goes directly to the user of the app. I agree that this is well within the book’s scope, and I hope that this was what you were referring to, since the majority of the book covers this type of communication!

Hope that helps :)

Michael James Williams August 31, 2011 at 11:39 pm

Just read your first comment again and want to make it clear that the book will not help with the ability to save extra information, such as which gifts a user has received, since that info must be saved server-side rather than client-side, and Facebook itself does not provide a means of saving data to its own servers. (Well, not beyond posting to people’s walls and so on.)

What you would need to do for this is create an server-side application for saving gift info, using Flash as the main interface, and then tie this into Facebook in two ways: first, by allowing Flash to communicate with Facebook, and second, by making the users’ data in your app’s server-side database correspond to their Facebook profiles.

In early drafts of the book I did plan to explain how to create such a server-side application and communicate with it via Flash, but eventually realised I couldn’t do it justice in just a couple of chapters. The good news is, you don’t need to buy a book specifically about server-side app development with Flash — since my book explains how to pass data to and from a server using Flash, you can get any book on server-side app development you want (PHP, ASP.NET, Python, whatever) and tie the two together.

Jeff Mullen September 7, 2011 at 7:43 am

Well…now you’ve gone and FORCED me to buy your book. ;) I’ll TRY to be polite when I write my usual scathing review. ;)

And if anyone tries to tell you that sarcasm is one of the many free services that I provide, you can tell ‘em I said, “No, not moi!” ;) ;) ;)

Hmmmmm…a new toy….

Leave a Comment

Writing code? Write <pre> at the start and </pre> at the end to keep it looking neat.

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: