I have a simple iPhone application I am making that will upload pictures to Facebook. To do this, I have to put multiple files on the server. From that, it will go to Facebook. I have my PHP code below that will do that server-side.
The problem is, when I put a variable in the array, it won’t work. I have tried all the different options and it’s not working out for me.
Any help is appreciated! Thanks.
$args = array(
'message' => 'Photo from the ******** iPhone Application.',
'$short_url' => '$short_url'
);
$url = 'https://graph.facebook.com/'.$album_id.'/photos?access_token='.$get_facebook_token;
$ch = curl_init();
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));
You are using single quotes were you probably should be using a variable directly or double quotes so the variable gets interpolated:
Or something like that. Depends on the supposed form field names. And “@$var” probaby leads to a file upload with curl.