2
I’m using a Face++ API for visual face recognition.
I set up a code in PHP that sends a face.jpg
to their API according to the rules in the documentation, but this Curl is either not sending the data or is not working, because on Linux on shell_exec
it works.
When trying to transfer the code to PHP it didn’t work.
My cUEL code on Linux that works:
curl -X POST "https://api-us.faceplusplus.com/facepp/v3/detect" -F "api_key=<api_key>" \
-F "api_secret=<api_secret>" \
-F "image_file=@image_file.jpg" \
-F "return_landmark=1" \
-F "return_attributes=gender,age"
My PHP code that brings me no return:
$data = array(
'api_key' => '<APIKEYAKI>',
'api_secret' => '<SECRETAKI>',
'return_landmark' => '1',
'return_attributes' => 'gender,age'
);
$data['image_file'] = '@./jasar.jpg';
$handle = curl_init('https://api-us.faceplusplus.com/facepp/v3/search');
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
$dados = curl_exec($handle);
curl_close($handle);
echo $dados;
I tried to change PHP codes; I picked up several examples right here on the site and nothing.
It follows updated Cod that already returns an error but now does not make the jpg post
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api-us.faceplusplus.com/facepp/v3/search");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "api_key=123456&api_secret=32164&return_attributes=gender,age&outer_id=facesetpocface&image_file=@".realpath('jasar.jpg'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
print($result);
Have you tried to put the full path to the image instead of the relative path?
– Woss
yes guy tried to user that real_patch of php.
– Jasar Orion
Try to direct this request with the
curl
for a page of yours and make sure the request is correct.– Woss
blank turn
– Jasar Orion
The answer, yes. But what about the request? That’s why I told you to make the request in your URL and debug the information that arrived.
– Woss
changed my Cod and now returns error but it is not doing the post of my jpg image I will update in the post
– Jasar Orion
Failed to put the answer you got with this new code.
– Woss
nothing comes atela gets blank tested on multiple servers and location.
– Jasar Orion