我正在尝试通过php应用程序上传图片。
Error :-
Uncaught CurlException: 26: failed creating formpost data thrown in
base_facebook.php on line 814
我的代码: -
$pic='img/'.$fbid.'.jpg';
$photo_details = array( 'message'=> "test", 'image' => '@' . realpath($pic), 'tags' => $tags );
$upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);
imagedestroy($image);
答案 0 :(得分:2)
好的,首先你不能同时上传和标记照片。您需要先上传照片然后标记它。所以代码将是
$args = array('message' => 'Testing photo tagging');
$args['image'] = '@' . realpath($FILE_PATH);
$data = $facebook->api('/me/photos', 'post', $args);
然后我们必须在图像上标记用户,但我发现我不能同时标记多个朋友,所以我不得不循环遍历数组。另一件事X&的价值标签数组中的Y不是px,它是百分比,因此这些值不会超过100
$photo_id = $data['id'];
$tags = array(
array(
'tag_uid' => 1337904214,
'tag_text' => 'Joy',
'x' => 50,
'y' => 30
),
array(
'tag_uid' => 709019872,
'tag_text' => 'test',
'x' => 100,
'y' => 100
)
);
foreach($tags as $t) {
$t = array($t);
$t = json_encode($t);
try {
$facebook->api('/' . $photo_id . '/tags', 'post', array('tags' => $t));
} catch (Exception $e) {
print_r($e);
}
}
祝你好运!