1.问题
当image_url参数 我换了什么图片链接都会出现
{"time_used": 35, "error_message": "INVALID_IMAGE_URL", "request_id": "1490261884,fc7b3994-1be7-412e-b7ae-6ff17ddffe61"}
2.官方参考文档
https://console.faceplusplus....
官方的PHP参考例子是2015年的
一些参数变了很多
https://github.com/FacePlusPl...
3.我的代码
"{$api_key}", "api_secret" => "{$api_secret}", "image_url" => "@$image_url", "return_landmark" => "{$return_landmark}", "return_attributes" => "{$return_attributes}" ]; //初始化一个cURL会话 $ch = curl_init(); // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 从证书中检查SSL加密算法是否存在 //设置请求选项 curl_setopt($ch, CURLOPT_URL, $detect_api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER,0); //这是请求类型 curl_setopt($ch, CURLOPT_POST, TRUE); //添加post数据到请求中 curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $response = curl_exec($ch); //错误处理 if($response == FALSE){ echo "错误信息:".curl_error($ch)."
"; } //获取curl请求的具体信息 $curl_info = curl_getinfo($ch); echo "收到的http回复的code:".$curl_info["http_code"]."
"; // curl_close($ch); //输出返回信息 var_dump($response);
$data = [
"api_key" => "{$api_key}",
"api_secret" => "{$api_secret}",
"image_url" => "$image_url",//不加@
"return_landmark" => "{$return_landmark}",
"return_attributes" => "{$return_attributes}"
];
//上传本地文件
$data = [
"api_key" => "{$api_key}",
"api_secret" => "{$api_secret}",
"image_file" => new CURLFile(realpath('test.jpg')),
"return_landmark" => "{$return_landmark}",
"return_attributes" => "{$return_attributes}"
];
//返回数组比较大
Array
(
[image_id] => w74xxf1O2bqKOo+vm0tQpQ==
[request_id] => 1490266400,f195454e-f957-4902-a446-f5fb70c6ab22
[time_used] => 304
[faces] => Array
(
[0] => Array
(
[landmark] => Array
(
[mouth_upper_lip_left_contour2] => Array
(
[y] => 351
[x] => 220
)
[mouth_upper_lip_top] => Array
(
[y] => 352
[x] => 241
)
[mouth_upper_lip_left_contour1] => Array
(
[y] => 350
[x] => 232
)
[left_eye_upper_left_quarter] => Array
(
[y] => 246
[x] => 149
)
[left_eyebrow_lower_middle] => Array
(
[y] => 230
[x] => 160
)
[mouth_upper_lip_left_contour3] => Array
(
[y] => 357
[x] => 225
)
[left_eyebrow_lower_left_quarter] => Array
(
[y] => 231
[x] => 145
)
[right_eyebrow_lower_left_quarter] => Array
(
[y] => 216
[x] => 261
)