Q:

Tagging friends on facebook Via Graphs

I am Trying to Tag a picture and posting it through graphs However, when I remove the 'tags'    => $tags from below, it works. Otherwise I get this error:
Array ( [error] => Array ( [message] => (#100) param tags must be an array. [type] => OAuthException [code] => 100 ) )

Here is my code:
<?php
$tags = array(
    'to' => $_SESSION['my_fb_id'],
    'x' => 0,
    'y' => 0
);

 $tag[]= $tags ;
//
//upload photo
$file = 'imgtmp/save_as_this_name.jpg';
$args = array(
    'message' => 'This is my Picture',
    'tags' => $tag, // IF this line is removed ,It works!
);
$args[basename($file)] = '@' . realpath($file);
$ch = curl_init();
$url = 'https://graph.facebook.com/me/photos?access_token=' . $_SESSION['access_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);
print_r(json_decode($data, true));
?>

A:

Tags must be array of tags as you can tag many people.
$tag1 = array(
    'tag_text' => 'tag test1',
    'tag_uid' => 'XXXXX1',
    'x' => 0,
    'y' => 0
);

$tag2 = array(
    'tag_text' => 'tag test2',
    'tag_uid' => 'XXXXX2',
    'x' => 0,
    'y' => 0
);

$tags = array($tag1, $tag2);

In your case 
$args = array(
    'message' => 'This is my Picture',
    'tags' => array( $tags ) , 
);

EDIT 1:
To tag photos successfully you will require user_photos permission.
Using graph api
$file = 'test.jpg';
$tags = array(
    'tag_text' => 'tag test',
    'tag_uid' => 'XXXXX',
    'x' => 10,
    'y' => 10
);

$args['tags'] = array($tags);
$args[basename($file)] = '@' . realpath($file);
$data = $facebook->api("/me/photos", "post", $args);

print_r($data);

Edit 2:
Just use json_encode for tags parameter
$args['tags'] = json_encode(array($tags));

This will solve the issue while using cURL.

