//时间戳13位毫秒
private function getMillisecond() {
list($s1,$s2) = explode(' ',microtime());
return (float)sprintf('%.0f',(floatval($s1) + floatval($s2)) * 1000);
}
// 组装参数
private function gysscPost1($url,$data)
{
// $data['timestamp'] = '1694402111964';
$data['timestamp'] = $this->getMillisecond();
$data['v'] = '1.0';
$data['appKey'] = $this->appKey;
$data['method'] = $data['method'];
$data['token'] = $this->token;
$data['format'] = 'json';
$data['paramType'] = 'json';
$contractBytes = $data['contractBytes']; // 上传pdf的文件地址
unset($data['contractBytes']);
ksort($data);
$data['sign'] = $sign_str;
$res = $this->curl1('http://39.101.164.226:8073/openapi', $data,$contractBytes);
$result = $this->decrypt($res); //解密
return $result;
}
public function curl1($url, $post,$contractBytes,$is_json = false,$aHeader='')
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL, $url);
// 重点是下面 传参
$post['contractBytes']= curl_file_create($contractBytes, mime_content_type($contractBytes), time() . 'pdf');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: multipart/form-data',
$aHeader
));
// 返回结果
$result = curl_exec($ch);
if($result != false)
{
curl_close($ch);
return $result;
} else {
$error = curl_errno($ch);
curl_close($ch);
return "curl出错,错误码:$error";
}
}
原文地址:https://blog.csdn.net/qq_39835505/article/details/134550185
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_5713.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。