views:

642

answers:

0

I have been trying to get a bit more familiar with the Graph API for facebook. Its very convenient although the documentation is poor at some places.

Im having trouble uploading an image to an album. Anyone know how to do it ?

This is the code im currently working on :)

 private function uploadNewPic(albumId:String):void
   {
    var bmd1:BitmapData = new BitmapData(200, 200, false, 0x666666);
    var bm1:Bitmap = new Bitmap(bmd1);
    var jpgEncoder:JPGEncoder = new JPGEncoder();
    var ba:ByteArray = jpgEncoder.encode(bmd1);
    var data:URLVariables = new URLVariables();
    data.message = "Message";
    data.image = ba;
    data.photos = ba;
    data.url = ba;

    var method:String = URLRequestMethod.POST;
    var loader:URLLoader = facebook.call(albumId + "/photos", data, method);
    loader.addEventListener(FacebookOAuthGraphEvent.ERROR, onPicError);
    loader.addEventListener(FacebookOAuthGraphEvent.DATA, onPicUploaded);


   }

Im pretty much down to trial and error :) Any ideas ?