Facebook Tagging friends to the picture

Posted by Rajesh Dante on Stack Overflow See other posts from Stack Overflow or by Rajesh Dante
Published on 2012-09-22T12:33:23Z Indexed on 2012/09/22 15:37 UTC
Read the original article Hit count: 220

Filed under:
|
|
|

Below code tag only first uid then then its shows Fatal error: Uncaught OAuthException: (#100) Invalid parameter and can i use exact location for tagging.. as in below code x and y values are in pixel

$facebook = new Facebook ( array (
        'appId' => FBAPPID,
        'secret' => FBSECRETID 
) );
$facebook->setFileUploadSupport ( true );
if (isset ( $_POST ['image'] ) && isset ( $_POST ['tname'] )) {

    $path_to_image = encrypt::instance ()->decode ( $_POST ['image'] );
    $tags = (array)encrypt::instance ()->decode ( $_POST ['tname'] );
    /*
     * Output
     $tags = array (
            0 => '[{"tag_uid":"100001083191675","x":100,"y":100},{"tag_uid":"100001713817872","x":100,"y":230},{"tag_uid":"100000949945144","x":100,"y":360},{"tag_uid":"100001427144227","x":230,"y":100},{"tag_uid":"100000643504257","x":230,"y":230},{"tag_uid":"100001155130231","x":230,"y":360}]' 
        );
     */

    $args = array (
            'message' => 'Von ',
            'source' => '@' . $path_to_image,
            'access_token' => $this->user->fbtoken 
    )
    ;
    $photo = $facebook->api ( $this->user->data->fbid . '/photos', 'post', $args ); // upload works but not tags

    if (is_array ( $photo ) && ! empty ( $photo ['id'] )) {
        echo 'Photo uploaded. Check it on Graph API Explorer. ID: ' . $photo ['id'];
        foreach ( $tags as $key => $t ) {
            $tagRe = json_encode ( $t );
            $args = array (
                    'tags' => $tagRe,
                    'access_token' => $this->user->fbtoken 
            );
            $facebook->api ( '/' . $photo ['id'] . '/tags', 'post', $args );
        }
    }
}

© Stack Overflow or respective owner

Related posts about php

Related posts about facebook