top.location.href='" . $dialog_url . "'"); } $token_url = "https://graph.facebook.com/oauth/access_token?client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url) . "&client_secret=" . $app_secret . "&code=" . $code; $response = file_get_contents($token_url); $params = null; parse_str($response, $params); $access_token = $params['access_token']; //get the user's photos and photo_id for the first pictre $post_url = "https://graph.facebook.com/me/photos?" . "access_token=". $access_token; $response = file_get_contents($post_url); $decoded_response = json_decode($response); $photo_id = $decoded_response->data[0]->id; //Tag friend_to_tag_id at position (x_coordinate, y_coordinate) $post_url = "https://graph.facebook.com/" .$photo_id . "/tags/" . $friend_to_tag_id . "?access_token=". $access_token . "&x=" . $x_coordinate . "&y=" . $y_coordinate . "&method=POST"; $response = file_get_contents($post_url); if ($response) { //Print the tag we just added show_tag_info($photo_id, $friend_to_tag_id, $access_token); //Update the x and y coordiates of the user_id $post_url = "https://graph.facebook.com/" .$photo_id . "/tags/" . $friend_to_tag_id . "?access_token=". $access_token . "&x=" . $x_new_coordinate . "&y=" . $y_new_coordinate . "&method=POST"; $response = file_get_contents($post_url); //Print the tag we just updated show_tag_info($photo_id,$friend_to_tag_id, $access_token); } else echo("errors"); //Function to print the tag information for friend_to_tag_id function show_tag_info($photo_id, $friend_to_tag_id, $access_token) { //get the tags on the picture $post_url = "https://graph.facebook.com/" . $photo_id ."/tags?access_token=". $access_token; $response = file_get_contents($post_url); $decoded_response = json_decode($response); //get the tag for friend_to_tag_id and display its coordinates foreach ($decoded_response->data as $tag) { $user_id = $tag->id; if ($user_id==$friend_to_tag_id) break; } $x = $tag->x; $y = $tag->y; $text= "user id= " . $user_id . " x = ". $x . " y = ". $y; echo ($text . “); } ?>