The content of this article is about how PHP calls the FACE API to implement url face comparison (code example). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
output code (out.php).
Face Compare System
php code
"https://api-cn.faceplusplus.com/facepp/v3/compare", //输入URL CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => array('image_url1'=>$image1,'image_url2'=>$image2, 'api_key'=>"p-4a6YPMwxYTfzt9bvY8hw3CFF1f0rt4",'api_secret'=>"hpWzxBorFtEcSfjvs9jbywp5g4RX2ef8"), //输入api_key和api_secret CURLOPT_HTTPHEADER => array("cache-control: no-cache",), )); curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { $arr=json_decode($response,true); echo "人脸匹配度为"; echo $arr["confidence"],"%"; } ?>
After configuring the php environment, place these two files in the root directory. Runnable.
Running effect:
Input:
Output:
Related recommendations:
The above is the detailed content of How does PHP call the FACE++ API to implement url face comparison (code example). For more information, please follow other related articles on the PHP Chinese website!