宝哥软件园

PHP微信红包生成代码分享

编辑:宝哥软件园 来源:互联网 时间:2021-09-07

本文实例为大家分享了服务器端编程语言(专业超文本预处理器的缩写)微信公众号自动发送红包应用程序接口代码,分享给大家供大家参考。具体如下:

贴出核心接口代码至于数据自己填写,接口测试好的微信_packet.php

!- ?php/** *发送红包接口*由PhpStorm创建*用户: ADKi *日期: 2016/4/25 0025 *时间: 15:25 */类微信_ packet { private $ URL='https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack';//请求统一资源定位器私有$ mch _ id//商户号private $ weixin _ appid//公众账号appid private $ send _ name//商户名称private $ total _ num=1;//发送红包总人数私人$许愿;//红包祝福语私有$ client _ ip//调用接口的机器互联网协议(互联网协议的缩写)地址private $ act _ name//活动名称私人$备注;//备注信息private $ nonce _ str//随机字符串,不长于32位private $ API _ password private $ arraytoxml//数组转xml /** *公钥*/private $ public _ key='/API/微信/cert/API client _ cert。PEM ';/** * 私钥*/private $ private _ key='/API/微信/cert/API client _ key。PEM ';/** * ca证书*/private $ root ca=' API/微信/cert/root ca。PEM ';public function __construct() { //初始化红包设置信息$ this-weixin _ appid=C(' WAP _ weixin _ appid ');$this-mch_id=C('微信_ mch _ id’);$this-send_name=C('微信_ send _ name’);$this-wishing=C('微信_ wishing’);$this-act_name=C('微信_ act _ name’);$ this-client _ IP=$ _ SERVER[' SERVER _ ADDR '];$这个-备注=C('微信_备注');$ this-nonce _ str=$ this-create _ nonce _ str(32);$this-api_password=C('微信_ API _ password’);$ Inc _ file=BASE _ path。ds。'美国石油学会'ds。'微信。DS。arraytoxml . phpif(is _ file($ Inc _ file)){ require($ Inc _ file);} $ this-ArrayToXML=new ArrayToXML();}公共函数send _ post($ mch _ billino,$re_openid,$ total _ amount){ $ sign=$ this-create _ sign($ mch _ billino,$re_openid,$ total _ amount);$ send _ array=array(' nonce _ str '=$ this-nonce _ str,' mch_billno'=$mch_billno,' mch_id'=$this-mch_id,' wxappid'=$this-weixin_appid,' send_name'=$this-send_name,' re_openid'=$re_openid,' total_amount'=$total_amount,' total_num'=$this-total_num ',许愿=$这个-许愿,' client _ IP '=$ this $ send _ XML=$ this-arraytoxml-ToxML($ send _ array ' ');$data=

更多资讯
游戏推荐
更多+