2014-01-12 29 views
0

我使用这个数组标记照片中的朋友,但没有人被标记,帮助我,如果我错了。通过facebook api标记代码没有反应

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

回答

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