This guide is not functional at this time due to changes to OAUTH 2.0 on the See:

. I might revise it in the future, but right now I’m tired of all these Facebook API changes.


Here’s an example of a Flash SWF that allows you to browse images (and swfs) from your computer, then post the uploaded images into your Facebook Photo Album using facebook-actionscript-api to

First, click the Login To Facebook button if you are not already logged in.

Then, an Upload Image button will appear. Click it and upload something.

Once the image is uploaded, another button labelled Save To Photo Album will appear. Click it to upload to your Facebook Photo Album.

Here’s a brief overview of how the code works, along with links to more detailed documentations and the link to the source FLA.

To post to your photo album, you can just use:

Facebook.api('me/photos', callback, params);

where the parameters contain an image field of a Bitmap object, a message string (which will appear as the caption of the photo in Facebook), and a fileName (this will not be displayed in Facebook and you can use generic name). Example:

	var params:Object = {image:myBitmap, message:'My Example Photo', fileName:'FILE_NAME'};
	Facebook.api('me/photos', callback, params);

This process of posting to the photo album is explained further in

The process of browsing and uploading files is explained in: (note: you do not need the server component since you will only be uploading to Facebook). FileReference is used to allow user to browse and upload images. Note that FileReference requires Flash player 10.

Here’s the link to the example as stand alone page:
The full source code of the FLA is here (requires Flash CS4 or newer): link.

9 Responses to “Using Facebook Graph API In Flash AS3 To Upload Image And Post To Photo Album”

  1. [...] Using Facebook Graph API In Flash AS3 To Upload Image And Post To Photo Album (英語) (投稿者:Kano) Comments: [...]

  2. very help full code ….. want to take a snapshot of the image uploaded and another one placed in front of it …
    and post the combined image

  3. Hi alex,
    Yup, you can combine the images in Flash before posting to Facebook.

  4. Hey there,

    I have a fan page with a custom tab that houses some flash in the canvas. I was wondering if you had any insight on how to post to the fan page feed. I feel like I have tried everything using your code as a basis and it always defaults to posting the image back to my wall.


  5. Hi Permadi! Nice job!

    Why you use 1.5 and not the latest library 1.8.1?

    “Facebook.getSession()” doesn’t exists in 1.8.1. Whats the procedure here?

  6. 1.8.1 wasn’t out when that tutorial was written.

  7. Check out: Haven’t tried that technique with Photo Album, but perhaps you can use the access_token to do it.

  8. i want to get 2 permission from users (publish_stream, user_photos) when i am trying this then its work but it ask twice facebook login popup :(
    please help me what i do

    Facebook.login(handleLogin, {scope:’publish_stream’});
    Facebook.login(handleLogin, {scope:’user_photos’});

  9. faixi,
    You should request the permissions in one call:
    Facebook.login(handleLogin, {scope:’publish_stream,user_photos’});

Leave a Reply