又没有人对接过旷视的上传识别照片API,总是提示参数错误,官方也没有参数示例,做过的能否帮忙给说一下

问题描述:

又没有人对结果旷视的上传识别照片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;
    }

<form action="{:url('adds')}" method="post" enctype="multipart/form-data" style="width:300px;margin:0 auto;margin-top:120px;"> 
          <div style="height:100px;width:220px;">
              <label>session</label>
              <input type="text" name="session" value="e87228c6f1-414b-4b23-ad50-ecf606ff7343d37">
          </div>
          <div style="height:100px;width:220px;">
              <label>subject_id</label>
              <input type="text" name="subject_id" value="1">
          </div>
          <div style="height:100px;width:220px;">
            <label>photo</label>
              <input name="photo" type="file" accept="image/gif, image/jpeg"/>
          </div>
          <input type="submit" value="上去把皮卡丘">
      </form> 

自己已经解决