Php Facebook Graph API:如何为上传的图像添加标题?

Php Facebook Graph API:如何为上传的图像添加标题?,php,facebook,facebook-graph-api,facebook-apps,Php,Facebook,Facebook Graph Api,Facebook Apps,我正试图将一张图片发布到facebook上的相册中,并用图片进行描述。 我可以将图像上传到相册,但似乎无法添加描述 以下是我使用的代码: // prepare the curl post fields $batch = sprintf('[{"method":"POST", "relative_url":"%1$s/photos", "attached_files":"file1", "message":"caption"}]', $album_id); $post_fields = ar

我正试图将一张图片发布到facebook上的相册中,并用图片进行描述。 我可以将图像上传到相册,但似乎无法添加描述

以下是我使用的代码:

// 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 );

我还尝试了一个名为“name”的post字段,但当我使用它时,结果得到了一个空数组。当我使用此帖子字段时,图像将不会添加到相册中。

请尝试更改您的$batch:


$batch = sprintf('[{"method":"POST", "relative_url":"%1$s/photos", "attached_files":"file1", "body" : "message=Your image caption"}]', $album_id); 
参考: 希望能有帮助