Hoping someone is fairly familiar with using the Flash Facebook api (v1.8.1) - first post to the forum so apologies if this is not the best place for my question…
I am using the api to upload images to an album as a batch request. I would like to be able to add a dependency that the first photo is uploaded before the rest to ensure that the first photo becomes the cover of the album.
I know that you can set dependencies through the Facebook Graph api using the “depends_on” attribute, but I am having difficulty trying to find out how to implement it using the the flash api, or if it’s even possible.
Can anyone point me in the right direction?
My working code, with no dependency, is below:
private function _onUploadClick(e:MouseEvent):void {
// create batch and add batchItem for each image
var batch:Batch = new Batch();
for(var i:int = 0; i < PhotoUploader.album.numPages; i++ ) {
batch.add(_uploadAlbumID + "/photos", _onImagePost, _getParams(i), URLRequestMethod.POST);
}
Facebook.batchRequest(batch, _onBatchComplete);
}
// Function to create params object for facebook image post
private function _getParams($index:int):Object {
var obj:Object = Object( _photoArray[$index] );
var postParams:Object = new Object();
postParams.message = obj.message;
postParams.access_token = accessToken;
postParams.image = obj.image.bitmapData;
postParams.fileName = 'image' + $index;
if($index > 0) postParams.no_story = 1; // only post first photo to wall
return postParams;
}