没有回复通过facebook api标记代码

时间:2014-01-12 03:13:19

标签: tagging photo-upload

我在照片中使用此数组用于标记朋友,但没有人被标记,如果我错了,请帮助我。

$tags = array( 
    "tag_uid" => $id,
    "tag_text" => $name,
    "x" => 20,
    "y" => 20
     );
 $facebook->api('/' . $new . '/tags?','post',  array( $tags ));

1 个答案:

答案 0 :(得分:1)

这是因为你没有做正确的标签数组。请尝试以下代码:

// Set tags limit
    $f1 = $facebook->api('me/friends?limit=10');

    // Get access token
    $access_token = $facebook->getAccessToken();

    // First post photo and then tag id
    $post_photo = $facebook->api('/me/photos', 'POST', array(
                                     'source' => '@' . $photo,
                                     'message' => $message
                                     )
                                  );
    // Creating Tags arrays for Tagging in the photo
    foreach($f1['data'] as $fbu){
    $tagx = array('tag_uid' => $fbu['id'],'x' => 30,'y' => 30 );
    $ftags[] = $tagx;
    }

    // Tags generated now giving variable
    $tagargs = array (
        'tags' => json_encode($ftags),
        'access_token' => $access_token,
    );

    // Posting the tags in photo
    $result = $facebook->api('/' . $post_photo['id'] . '/tags', 'post', $tagargs);