又没有人对结果旷视的上传识别照片API,总是提示参数错误,官方也没有参数示例,做过的能否帮忙给说一下
{code: -1002, data: {}, desc: "参数错误"}
code: -1002
data: {}
desc: "参数错误"
public function api_img_check()
{
header("Content-type: text/html; charset=utf-8");
$id = 1;
$img = request()->file('file');
$img_data = $this->upload_post($img);
$url = 'D:\www\zhcs\public\uploads\api\\';
if($img_data)
{
$img_data = $url.$img_data;
}
else
{
return '图片上传接口出错';
}
$data = [
'photo' => "@".realpath($img_data),
'subject_id' => $id,
];
$http_curl = new AoalaCurl();
$photo = config('koala.photo');
$api_mobile = $http_curl->http_post_curl_img($photo,$data,true);
echo $api_mobile;
}
public function http_post_curl_img($path,$data,$isfile=false)
{
//初始化
self::Init();
$this->path = self::$koala_url.$path;
if ($data && $isfile == true){
$this->postdata = $data;
}
elseif($data && $isfile == false)
{
$this->postdata = $this->buildJsonQuery($data);
}
echo '<pre>';
echo $this->path;
var_dump($data);
die;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->path);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_USERAGENT, self::$user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_COOKIEJAR, self::$cookiefile);
curl_setopt($ch, CURLOPT_COOKIEFILE, self::$cookiefile);
if(!$isfile){
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type:'.self::$content_type_img,
'Content-Length:'.strlen($this->postdata))
);
}
// var_dump($this->postdata);
// var_dump(http_build_query($this->postdata));die;
curl_setopt($ch,CURLOPT_POSTFIELDS,$this->postdata);
// curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($this->postdata));
$result = curl_exec($ch);
curl_close($ch);
return $result;
}