使用PHP无法上传和标记照片在Facebook应用程序? [英] Unable to upload and tag photo on Facebook application using PHP?

查看:81
本文介绍了使用PHP无法上传和标记照片在Facebook应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 错误: -  

未捕获CurlException:26:在

中创建formpost数据失败在第814行

我的代码: -

  $ pic ='img /'.$ fbid''jpg' 



$ photo_details = array('message'=>test,'image'=>'@'realpath($ pic) => $标签);
$ upload_photo = $ facebook-> api('/'.$ album_uid。'/ photos','post',$ photo_details);

imagedestroy($ image);


解决方案

好的,首先你不能上传和标记照片与此同时。您需要首先上传照片,然后将其标记。所以代码将是

  $ args = array('message'=>'测试照片标记'); 
$ args ['image'] ='@'。真实路径($ 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
),
数组(
'tag_uid'=> 709019872,
'tag_text'= >'test',
'x'=> 100,
'y'=> 100

);

foreach($ tags as $ t){
$ t = array($ t);
$ t = json_encode($ t);
尝试{
$ facebook-> api('/'。$ photo_id。'/ tags','post',array('tags'=> $ t));
} catch(Exception $ e){
print_r($ e);
}
}

祝你好运!


I am trying to upload an image through php app.

Error :-

Uncaught CurlException: 26: failed creating formpost data thrown in

base_facebook.php on line 814

My Code :-

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

解决方案

OK , first of all you cant upload and tag photos at the same time. You need to upload the photo first then tag it . So the code will be

$args = array('message' => 'Testing photo tagging');
$args['image'] = '@' . realpath($FILE_PATH);
$data = $facebook->api('/me/photos', 'post', $args);

then we have to tag the users on the image , but i found that i cant tag more than one friend at the same time so i had to loop through the array. Another thing the value of X & Y in the tag array is not the px , its the percentage so those values will not exceed 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);
    }
}

Good Luck !

这篇关于使用PHP无法上传和标记照片在Facebook应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆