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.我的代码
<?php
/**
* 问题:
* image_url 当带入图片链接 我是用的您官网的图片链接
* 返回错误信息
* '{"time_used": 23, "error_message": "INVALID_IMAGE_URL", "request_id": "1490260190,5fcf1ce6-53c2-4652-b67a-4808b2bdd5a2"}'
* 换了图片链接也一样
*/
$api_key = "cK25pkbERhS8UoPWw2dBKWsNnGPdn6vG";
$api_secret = "oo8swPRXW3bwV_JxSBGO6sjK-b-wemyI";
$detect_api_url ="https://api-cn.faceplusplus.com/facepp/v3/detect";
//image_url
$image_url = "https://bj-mc-prod-asset.oss-cn-beijing.aliyuncs.com/mc-official/images/demo/demo-pic11.jpg";
//image_file
$image_file = "D:/image/01.jpg";
$image_info = getimagesize($image_file);
$image_data = fread(fopen($image_file, 'r'), filesize($image_file));
$image_file = base64_encode($image_data);
$return_landmark = "1";
$return_attributes="gender";
$url = "{$detect_api_url}";
$data = [
"api_key" => "{$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)."<br/>";
}
//获取curl请求的具体信息
$curl_info = curl_getinfo($ch);
echo "收到的http回复的code:".$curl_info["http_code"]."<br/>";
//
curl_close($ch);
//输出返回信息
var_dump($response);