taggingphoto-upload

No Response Through facebook api tag code


i am using this array for tag friends in a photo but no one is tagged , help me if i wrong.

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

Solution

  • this is because you are not doing the correct tags arrays. Try the following codes:

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