{ "image_reset": "NTyDKpmLM7RklVcRyv2xPA==", "request_id": "1528687092,efbe87f7-6c0f-4754-b108-afe8f42abe17", "time_used": 666, "face_rectangle": { "top": 1, "left": 1, "width": 1, "height": 1 }, "result": { "left_eyelids": { "value": "0", "confidence": 0.89 }, "right_eyelids": { "value": "0", "confidence": 0.89 }, "eye_pouch": { "value": "0", "confidence": 0.89 }, "dark_circle": { "value": "0", "confidence": 0.89 }, "forehead_wrinkle": { "value": "0", "confidence": 0.89 }, "crows_feet": { "value": "0", "confidence": 0.89 }, "eye_finelines": { "value": "0", "confidence": 0.89 }, "glabella_wrinkle": { "value": "0", "confidence": 0.89 }, "nasolabial_fold": { "value": "0", "confidence": 0.89 }, "skin_type": 0, "details": { "0": { "value": 1, "confidence": 0.89 }, "1": { "value": 1, "confidence": 0.89 }, "2": { "value": 0, "confidence": 0.01 }, "3": { "value": 0, "confidence": 0.01 } }, "pores": { "value": "0", "confidence": 1 }, "pores_forehead": { "value": "0", "confidence": 1 }, "pores_left_cheek": { "value": "0", "confidence": 1 }, "pores_right_cheek": { "value": "0", "confidence": 1 }, "pores_jaw": { "value": "0", "confidence": 1 }, "blackhead": { "value": "0", "confidence": 1 }, "acne": { "value": "0", "confidence": 1 }, "mole": { "value": "0", "confidence": 1 }, "skin_spot": { "value": "0", "confidence": 1 } } }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2020/10/10 17:50 */ //---------------------------------- // 皮肤分析 调用类 //---------------------------------- class freeApi { private $apiKey = false; private $apiSecret = false; private $apiUrl = 'https://api-cn.faceplusplus.com/facepp/v1/skinanalyze'; public function __construct($apikey,$apiSecret){ $this->apiKey = $apikey; $this->apiSecret = $apiSecret; } /** * 将JSON内容转为数据,并返回 * @param string $content [内容] * @return array */ public function returnArray($content){ return json_decode($content,true); } /** * 获取结果 * @return array */ public function getResult(){ $params = [ "api_key" => $this->apiKey, "api_secret" => $this->apiSecret, "image_url" => "", ]; $params = http_build_query($params); return $this->returnArray($this->freeApiCurl($this->apiUrl,$params,1)); } /** * 请求接口返回内容 * @param string $url [请求的URL地址] * @param string $params [请求的参数] * @param int $ipost [是否采用POST形式] * @return string */ public function freeApiCurl($url,$params=false,$ispost=0){ $ch = curl_init(); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 ); curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST , false ); curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER , false ); curl_setopt( $ch, CURLOPT_USERAGENT , 'chuanshuoapi' ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 ); curl_setopt( $ch, CURLOPT_TIMEOUT , 60); curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true ); if( $ispost ) { curl_setopt( $ch , CURLOPT_POST , true ); curl_setopt( $ch , CURLOPT_POSTFIELDS , $params ); curl_setopt( $ch , CURLOPT_URL , $url ); } else { if($params){ curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params ); }else{ curl_setopt( $ch , CURLOPT_URL , $url); } } $response = curl_exec( $ch ); if ($response === FALSE) { return false; } curl_close( $ch ); return $response; } }