2012-02-24 102 views
0

我想將圖像發佈到臉書上的相冊,並與圖像放置描述。 我可以將圖像上傳到相冊,但我似乎無法添加說明。Facebook Graph API:如何爲您上傳的圖片添加標題?

這裏是我使用的代碼:

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

我也試圖與所謂的「名」後場,但是當我用這個,我得到一個空數組結果。當我使用這個後場時,圖像不會被添加到相冊中。

回答

0

試着改變你的$批次:

 

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

編號:Batch Upload 希望它可以幫助

+0

感謝,這工作。 – ThoDho 2012-02-24 11:05:49

相關問題