无法使用PHP在Facebook应用程序上上载和标记照片?
我正在尝试通过php应用程序上传图像无法使用PHP在Facebook应用程序上上载和标记照片?,php,facebook,Php,Facebook,我正在尝试通过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), '
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);
好的,首先你不能同时上传和标记照片。你需要先上传照片,然后贴上标签。因此,代码将是
$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);
}
}
祝你好运 您现在可以同时上传照片和标签。