利用PHP怎么实现一个微信企业向用户付款的功能-创新互联
利用PHP怎么实现一个微信企业向用户付款的功能?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

具体如下:
$v) {
$str.=$k.'='.$v.'&';
}
$str.='key='.$secrect_key;
$data['sign']=md5($str);
$xml=arraytoxml($data);
// echo $xml;
$url='https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers';
$res=curl($xml,$url);
$return=xmltoarray($res);
print_r($return);
// echo getcwd().'/cert/apiclient_cert.pem';die;
function unicode() {
$str = uniqid(mt_rand(),1);
$str=sha1($str);
return md5($str);
}
function arraytoxml($data){
$str='';
foreach($data as $k=>$v) {
$str.='<'.$k.'>'.$v.''.$k.'>';
}
$str.=' ';
return $str;
}
function xmltoarray($xml) {
//禁止引用外部xml实体
libxml_disable_entity_loader(true);
$xmlstring = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
$val = json_decode(json_encode($xmlstring),true);
return $val;
}
function curl($param="",$url) {
$postUrl = $url;
$curlPost = $param;
$ch = curl_init(); //初始化curl
curl_setopt($ch, CURLOPT_URL,$postUrl); //抓取指定网页
curl_setopt($ch, CURLOPT_HEADER, 0); //设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1); //post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); // 增加 HTTP Header(头)里的字段
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // 终止从服务端进行验证
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch,CURLOPT_SSLCERT,getcwd().'/cert/apiclient_cert.pem'); //这个是证书的位置
curl_setopt($ch,CURLOPT_SSLKEY,getcwd().'/cert/apiclient_key.pem'); //这个也是证书的位置
$data = curl_exec($ch); //运行curl
curl_close($ch);
return $data;
}看完上述内容,你们掌握利用PHP怎么实现一个微信企业向用户付款的功能的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!
当前标题:利用PHP怎么实现一个微信企业向用户付款的功能-创新互联
浏览地址:http://www.jxjierui.cn/article/dcgchg.html


咨询
建站咨询
