Posted By

Matias on 02/03/12


Tagged

image upload api graph photo facebook


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Matias
fedecp


Upload Image To Facebook using GraphAPI_Web.swc in as3


 / Published in: ActionScript 3
 

i assume that the Facebook api has been initialized and i have the "publish_stream permission" the picture can be taken of a particular area of the displayObject

  1. public function PostImageToAlbum(message : String,image : DisplayObject,clipRect : Rectangle ) : void
  2. {
  3. var bd:BitmapData = new BitmapData(clipRect.width,clipRect.height,true,00000000);
  4. var AuxBData : BitmapData = new BitmapData(image.width,image.height,true,0);
  5. AuxBData.draw(image,null,null,null,clipRect);
  6. bd.copyPixels(AuxBData,clipRect,new Point(0,0));
  7. var result:Bitmap = new Bitmap(bd);
  8. var params: Object = new Object;
  9. var encoder:JPGEncoder = new JPGEncoder(75);
  10. var bytes:ByteArray = encoder.encode(result.bitmapData);
  11. params.message = message;
  12. params.image = bytes;
  13. params.fileName = "image.jpg";
  14. Facebook.api("/me/photos",null,params,"POST");
  15. }

Report this snippet  

You need to login to post a comment.