How to Upload Inline-Images using Graph API Batch Request?

The first issue I see is that the Batch should not be part of the URL, but rather part of the params.

The first issue I see is that the Batch should not be part of the URL, but rather part of the params ... See the crude batch example below: $batch = array(); $req = array( 'method' => 'GET', 'relative_url' => '/me' ); $batch = json_encode($req); $req = array( 'method' => 'GET', 'relative_url' => '/me/albums' ); $batch = json_encode($req); $params = array( 'batch' => '' . Implode(',',$batch) . '' ); try { $info = $facebook->api('/','POST',$params); } catch(FacebookApiException $e) { error_log($e); $info = null; } if(!empty($info)){ if($info0'code' == '200'){ $user_profile = json_decode($info0'body'); } if($info1'code' == '200'){ $user_albums = json_decode($info1'body'); } echo "User Profile:\n"; print_r($user_profile); echo "\nAlbums\n"; print_r($user_albums); echo ""; } Notice specifically how the $facebook->api call is formatted ... EDIT: Here is a working batch picture upload: $files = array( '/data/Pictures/pic1.

Jpg', '/data/Pictures/pic2. Jpg', '/data/Pictures/pic3. Jpg' ); //Must set upload support to true $facebook->setFileUploadSupport(true); $batch = array(); $params = array(); $count = 1; foreach($files as $file){ $req = array( 'method' => 'POST', 'relative_url' => '/me/photos', 'attached_files' => 'file' .

$count ); //add this request to the batch ... $batch = json_encode($req); //set the filepath for the file to be uploaded $params'file'. $count = '@' . Realpath($file); $count++; } $params'batch' = '' .

Implode(',',$batch) . ''; try{ $upload = $facebook->api('/','post',$params); } catch(FacebookApiException $e) { error_log($e); $upload = null; } //View the results ... if(!is_null($upload)){ echo "" . Print_r($upload,1) .""; echo ""; } Just tested and it works like a charm ...

Awesome man, Finally it works :) thanks mate. – SIR Jul 15 at 22:01 Nice and clear, thanks! – Aston Jul 16 at 11:30.

Well, I'm not too sure and I cannot check at the moment, but au.php.net/manual/en/function.curl-setop... Look it up at CURLOPT_POSTFIELDS, it says: The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. The filetype can be explicitly specified by following the filename with the type in the format ';type=mimetype'.

This parameter can either be passed as a urlencoded string like 'para1=val1¶2=val2&...' or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data. As of PHP 5.2.0, files thats passed to this option with the @ prefix must be in array form to work.

Here is another CURL example: CURL PHP send image So what you need to do is $queries = array( array("method" => "POST", "relative_url" => "me/photos","body" => "message=cool","attached_files" => 'file1') ); and $batch = $facebook->api("/? Batch=". Json_encode($queries)."&file1=@pic.

Jpg", 'POST').

Nope, its not working :( tried few other things as well, but no luck:S – SIR Jul 15 at 21:16.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions