Take the 2-minute tour ×

I am trying to post an image to an album on facebook and place a description with the image. I can upload the image to an album, but i can't seem to add the description.

Here is the code I use:

// prepare the curl post fields
$batch = sprintf('[{"method":"POST", "relative_url":"%1$s/photos", "attached_files":"file1", "message":"caption"}]', $album_id);  

$post_fields = array(
'batch' => $batch,
'access_token' => $access_token,
'file1' => '@' . $image_abs_path,
'caption' => 'image caption goes here"
$uri = 'https://graph.facebook.com';

$curl = curl_init( $uri );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );  
curl_setopt( $curl, CURLOPT_POST, TRUE );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $post_fields );  

$raw_data = curl_exec( $curl );
curl_close( $curl );

$data = json_decode( $raw_data, $assoc = TRUE );

I also tried with a post-field called "name", but when I use this I get an empty array as a result. The image will not be added to the album when I use this post-field.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Try changing your $batch:

$batch = sprintf('[{"method":"POST", "relative_url":"%1$s/photos", "attached_files":"file1", "body" : "message=Your image caption"}]', $album_id); 

Ref: Batch Upload Hope it helps

share|improve this answer
thanks, this works. –  ThoDho Feb 24 '12 at 11:05

Your Answer


