So I'm attempting to use an api called Sky Biometry, which is used for face detection and facial recognition. The api either accepts a url or a post as a MIME type. In this case I would like to directly post the picture to the api, here is what the documentation says:
"Note: in case where you want to POST images instead of specifying urls, request to the method must be formed as a MIME multi-part message sent using POST data. Each argument should be specified as a separate chunk of form data."
I've tried looking around for examples, but have yet to find any, if somebody could help a newbie out it would be greatly appreciated.
Multipart messages are actually standard POST enctype="multipart/form-data" requests. You can generate them quite simply with a simple form, or you can use cURL (as I suspect you are already doing) as follows:
curl_setopt($channel, CURLOPT_POSTFIELDS, array("myfile" => "@/path/to/my/image.png"));
cURL will automatically do the rest (convert your content-type and mime-type it).
This an example structure of posting values using curl,
$value1 = 'DATA 1;
$value2 = 'DATA 2';
$url = 'http://www.skybiometry.com/file/api/facedetection/example';
$fields = array(
'mimetype' => urlencode($value1),
'mimetype2' => urlencode($value2)
);
//url-ify the data for the POST
$fields_string = '';
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
Hope this might help you.