Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用PHP在Facebook应用程序上上载和标记照片?_Php_Facebook - Fatal编程技术网

无法使用PHP在Facebook应用程序上上载和标记照片?

无法使用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), '

我正在尝试通过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);

好的,首先你不能同时上传和标记照片。你需要先上传照片,然后贴上标签。因此,代码将是

$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);
    }
}

祝你好运

您现在可以同时上传照片和标签。