apiClient = new \DefaultIcbcClient( $this->APP_ID, $this->PRI_KEY, $this->signType, '', '', $this->APIGW_PUBLIC_KEY, '', '', '', '' ); } public function test(){ $request = [ 'serviceUrl' => 'https://gw.open.icbc.com.cn/api/mybank/enterprise/pay/payent/V1', 'method' => 'POST', 'isNeedEncrypt'=>false, 'biz_content' => array( "channelFlag"=>2, "empowerPhone"=>"18868040087", "applyType"=>"00100", "crftType1"=>"101", "crftNo1"=>"914310236828465718" ), 'extraParams'=>[] ]; $res = $this->apiClient->execute($request,$this->getMsgId(),""); } public function getMsgId(){ return substr(md5("donglonghui".time().mt_rand(1,1000000)),8,13); } public function abutmentContent(){ $data=[ "app_id"=> $this->app_id, "timestamp"=>date("Y-m-dH:i:s"), "notify_url"=>"https://dlh.hainings.com/index/index/localReturn" ]; ksort($data); print("
");
var_dump($data);
$data['msg_id'] = $this->getId("donglonghui",$data);
$data1 = http_build_query($data);
$url = "https://gw.open.icbc.com.cn/api/mybank/enterprise/pay/payent/V1";
$res = $this->curl_post($url,$data1);
// var_dump($res);
$data['sign'] = $res['sign'];
// var_dump($data);
$d=[
"channelFlag"=>2,
"empowerPhone"=>"18868040087",
"applyType"=>"00100",
"crftType1"=>"101",
"crftNo1"=>"914310236828465718"
];
$u = "https://gw.open.icbc.com.cn/api/mybank/cardbusiness/shop/MerRegistrationAdd/V1";
$d1= http_build_query($d);
$rest = $this->curl_post($u,$d1);
var_dump($rest);
}
function getId($app_secret, $req_param=[])
{
// 排序所有请求参数
ksort($req_param);
$src_value = "";
// 按照key1value1key2value2...keynvaluen拼接
foreach ($req_param as $key => $value) {
$src_value .= ($key . $value);
}
//计算md5
return md5($app_secret . $src_value . $app_secret);
}
private function curl_post($url,$postdata){
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检测
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Expect:'
)); // 解决数据包大不能提交
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); // Post提交的数据包
curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
$tmpInfo = curl_exec($curl); // 执行操作
if (curl_errno($curl)) {
echo 'Errno' . curl_error($curl);
}
curl_close($curl); // 关键CURL会话
$tmpInfo=json_decode($tmpInfo,true);
return $tmpInfo;
}
}