Wie kann ich Fotos in Facebook-API markieren?

Ich wollte fragen, ob / wie es möglich ist, ein Foto mit der FB-API (Graph oder REST) zu markieren.

Ich habe es geschafft, ein Album zu erstellen und auch ein Foto darin hochzuladen, aber ich bin beim Taggen geblieben.

Ich habe die Berechtigungen und den richtigen Sitzungsschlüssel.

Mein Code bis jetzt:

try {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
    $token = $session['access_token'];//here I get the token from the $session array
    $album_id = $album[0];

    //upload photo
    $file= 'images/hand.jpg';
    $args = array(
        'message' => 'Photo from application',
    );
    $args[basename($file)] = '@' . realpath($file);

    $ch = curl_init();
    $url = 'https://graph.facebook.com/'.$album_id.'/photos?access_token='.$token;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
    $data = curl_exec($ch);

    //returns the id of the photo you just uploaded
    print_r(json_decode($data,true));

    $search = array('{"id":', "}");
    $delete = array("", "");

    // picture id call with $picture
    $picture = str_replace($search, $delete, $data);

    //here should be the photos.addTag, but i don't know how to solve this
    //above code works, below i don't know what is the error / what's missing

    $json = 'https://api.facebook.com/method/photos.addTag?pid='.urlencode($picture).'&tag_text=Test&x=50&y=50&access_token='.urlencode($token);

    $ch = curl_init();
    $url = $json;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_exec($ch);
} catch(FacebookApiException $e){
    echo "Error:" . print_r($e, true);
}

Ich habe wirklich lange gesucht, wenn du etwas weißt, das mir helfen könnte, poste es bitte hier :) Danke für all deine Hilfe, Camillo

Antworten auf die Frage(6)

Ihre Antwort auf die Frage