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:

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


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 ) , 


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


Edit 2:

Just use json_encode for tags parameter

$args['tags'] = json_encode(array($tags));

This will solve the issue while using cURL.

Need Your Help

importing mysqlclient in visual basic.net

vb.net mysql

Can anyone help me on how can I import "System.Data.MySqlClient" in visual basic.net?

P2P NFC Communication Between Android Phone(Nexus S) and NFC Reader?

android nfc nexus-s nfc-p2p

I need to establish a P2P connection between my Nexus S and a NFC Reader which is attached to my desktop. Can anybody tell me how to do that. I do not even know how to start.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.