我按照官方给的步奏
这个是我的生成签名的代码实现
$dataArr=array();
$dataArr['appid']=APPID;
$dataArr['mch_id']=$mch_id;
$dataArr['device_info']='1000';
$dataArr['body']='test';
$dataArr['nonce_str']=$nonce_str;
$sign=getSign($dataArr);//签名
function getSign($dataArr)
{
foreach ($dataArr as $k => $v)
{
$Parameters[$k] = $v;
}
//签名步骤一:按字典序排序参数
ksort($Parameters);
$String = formatBizQueryParaMap($Parameters, false);//方法如下
//echo '【string1】'.$String.'';
//签名步骤二:在string后加入KEY
$String = $String."&key=XXXXXXX";
//echo "【string2】".$String."";
//签名步骤三:MD5加密
$String = md5($String);
//echo "【string3】 ".$String."";
//签名步骤四:所有字符转为大写
$result_ = strtoupper($String);
//echo "【result】 ".$result_."";
return $result_;
}
然后在线签名验证 结果一致
但是到了RSA加密这一步
返回的xml却是
签名出错。。。
curl请求的函数是
function RAS($mch_id,$nonce_str,$sign){
$data="
".$mch_id."
".$nonce_str."
".$sign."
";\
$url="https://fraud.mch.weixin.qq.com/risk/getpublickey";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch,CURLOPT_SSLCERT,'./WxpayAPI_php/cert/apiclient_cert.pem');
curl_setopt($ch,CURLOPT_SSLKEY,'./WxpayAPI_php/cert/apiclient_key.pem');
curl_setopt($ch,CURLOPT_CAINFO,'./WxpayAPI_php/cert/rootca.pem');
$content=curl_exec($ch);
curl_close ( $ch );
echo $content
}
不知道哪里出错了.....