edit:
<?php
$file= 'fbplus.jpg';
$args = array(
'message' => $album_message,
);
$args[basename($file)] = '@' . realpath($file);
$ch = curl_init();
$url = $graph_url;
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 photo id
print_r(json_decode($data,true));
echo "$data['id'] "; //wont work
echo "$data[id] "; //wont work
?>
this was the return, after i successfully uploaded a photo.
Array ( [id] => 112235735579158 [post_id] => 100003781972892_112203478915717 )
curl_exec()returns a string (contents of the webpage), not anArray. So you cannot do$data['id']because$datais a string and not an array.What is the url you are posting to? What is its exact output?
EDIT: Looks like the url returns JSON. In that case: