Here’s my code block:
// set up picture
$animetrics_api_key ='be1cfaea79d6160e1571bd56e24fcb97';
// $animetrics_api_key = "66a6ffce3f6c402ff2e9e69dbc522722"; // fudan mail API
$photo_url = "http://api.animetrics.com/img/test/sc.jpg";
// features extraction
$data = array('api_key'=>$animetrics_api_key, 'url'=> $photo_url); //'image'=>'@'.$path_to_local_file);
// $data = array(
// "selector" => "FACE, EYES, FULL",
// "url" => "http://api.animetrics.com/img/test/sc.jpg"
// );
$headers = array(
"X-Mashape-Key" => "75DpeDVzr9mshQ0bnpmZDNfiTNhcp1Z1SmJjsnUYhb5Ngif2Ea"//,
// "Content-Type" => "application/x-www-form-urlencoded",
// "Accept" => "application/json"
// “X-Mashape-Key: 75DpeDVzr9mshQ0bnpmZDNfiTNhcp1Z1SmJjsnUYhb5Ngif2Ea”,
// “Content-Type: application/x-www-form-urlencoded”,
// “Accept: application/json”
);
ch, CURLOPT_URL, ‘http://api.animetrics.com/v1/detect’);
curl_setopt(ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt(ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ch, CURLOPT_POSTFIELDS, $data);
ch);
echo $response;
But it always return the error message that it can’t detect my Mashape application key. Would appreciate some help, thanks.
ディスカッションに参加しましょう-以下にコメントを追加してください:
Glad you got it working!
Whoops, forgot to close.
Hey there I change two things and it’s now working:
First I changed the ‘image’ field to ‘url’ in the data array,
Second, I added an element in the data array - ‘selector’=> “FULL”, so it returns with the full array of all coordinates of the face in the photo.
Here’s the entire working code block:
Thanks for all your help and super rapid response! 😃
Have a nice one.
Hi there - thanks for the quick response. And sorry about the code block - I must have forgotten to preview.
In any case, I’ve tried running this code block, and the request is sent, however, the response body is empty. All I did was to modify the $mashape_key, $animetrics_api_key, $path_to_local_file fields - I tried two variations of the $path_to_local_file variable - an online photo’s URL and a local photo’s URL, to no avail.
To be more precise, I commented the three conditions that threw a “no faces found in response”, and tried each condition in turn - and it was the last condition in the if statement that threw this error:
Also, for the online photo, the URL I tried was this: http://api.animetrics.com/img/test/sc.jpg.
Would appreciate your advice on this, thanks!
Please do not post your api and mashape keys publicly. Difficult to read your code because the formatting got messed up but the following modification of our example works.