VPS参考测评推荐
专注分享VPS主机优惠信息
衡天云优惠活动
华纳云最新优惠促销活动
jtti最新优惠促销活动

微信api接口(微信API接口地址)

locvps
主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作

本文介绍的内容是关于微信API接口的,有一定的参考价值。现在分享给大家,有需要的朋友可以参考一下。

本文介绍个人总结的一些微信API接口,包括微信支付、微信红包、微信卡券、微信商店等。,这些都很全面,有需要的朋友可以参考一下。

微信入口绑定、微信事件处理、微信API的所有操作都包含在这些文件中。微信支付,微信红包,微信卡券,微信商店。

1.[code ]index.php

lt马鞭phpinclude _ once # 39lib . Inc . PHP # 39;;$wcObj =新微信( 游奎元 );$ WCO bj - gt;wcValid();2.【代码】微信门户类

lt马鞭php/** *微信描述* * @作者管理员*/类微信扩展WxApi { public $ token = ";//将您的代码放在这里public function _ _ construct($ token = ;"){ parent::_ _ construct();$ this - gt;token = $ token}公共函数wcCheckSignature(){ try { if(empty($ this - gt;token)) {抛出新的异常( # 39;令牌未定义!');} $ signature = $ _ GET[ ;签名 ];$ timest = $ _ GET[ ;时间戳 ];$ nonce = $ _ GET[ ;nonce ];$ token = $ this - gt;token$tmpArr = array($token,$timest,$ nonce);//使用SORT_STRING规则排序($tmpArr,SORT _ STRING);$tmpStr =内爆($ TM parr);$ tmp str = sha1($ tmp str);if($ tmpStr = = $ signature){ return true;}else{返回false} } catch(异常$ e){ echo # 39;消息: # 39;。$ E->;getMessage();} }公共函数wcValid(){ $ echoStr = isset($ _ GET[ ;echostr ]) ; !empty($ _ GET[ ;echostr ]) ?add slashes($ _ GET[ ;echostr ]):NULL;if(is _ null($ echoStr)){ $ this - gt;wcMsg();} else {//有效签名,option if($ this - gt;wcCheckSignature()){ echo $ echoStr;退出;} else { exit();} } }公共函数wcMsg(){//获取post数据,可能是由于环境不同$ postStr = isset($ GLOBALS[ ;HTTP _ RAW _ POST _ DATA ]) ; !空($GLOBALS[ ;HTTP _ RAW _ POST _ DATA ]) ?$ GLOBALS[ ;HTTP _ RAW _ POST _ DATA ]: ;";如果(!empty($ postStr)){ libxml _ disable _ entity _ loader(true);$ post obj = SimpleXML _ load _ string($ postStr, # 39;SimpleXMLElement # 39,LIBXML _ NOCDATA);$ this - gt;zcLog(TRUE,$ post obj);$ from username = $ postobj - gt;from用户名;$ touser name = $ postobj - gt;ToUserName$ MsgType = $ postobj - gt;MsgTypeif($ MsgType = = # 39;事件 # 39;){//执行$ event = $ postobj->对应的事件;事件;开关($ Event){ case # 39;订阅 # 39;://注意破;案例 # 39;退订 # 39;://unfollow break;案例 # 39;扫描 # 39;://扫描中断;案例 # 39;位置 # 39;://地址中断;案例 # 39;点击 # 39;://点击时间休息;案例 # 39;查看 # 39;://跳转中断;案例 # 39;卡_通行证_支票 # 39;://卡券通过了断档;案例 # 39;card _ not _ pass _ check # 39://卡片凭证审核中断失败;案例 # 39;user _ get _ card # 39://用户获得卡券折;案例 # 39;user _ del _ card # 39://用户删除卡券折;案例 # 39;user _ view _ card # 39://用户浏览会员卡休息;案例 # 39;user _ consume _ card # 39://用户注销卡凭证断;案例 # 39;merchant _ order # 39://微店用户下单付款中断;默认:break} } else { switch($ MsgType){ case # 39;正文 # 39;://文本格式中断;案例 # 39;图像 # 39;://图片格式中断;案例 # 39;声音 # 39;://音断;案例 # 39;视频 # 39;://视频中断;案例 # 39;短视频 # 39;://小视频休息;案例 # 39;位置 # 39;://上传地理位置break案例 # 39;链接 # 39;://链接相应的break默认:break} }///////////////////////////////////////////////////$ keyword = trim($postobj - gt;内容);$ time = time();$ textTpl = ltxml gt ltToUserName gt lt![CDATA[% s]] gt; lt/touser name gt; ltfrom用户名 gt lt![CDATA[% s]] gt; lt/from username gt; ltCreateTime gt% s lt/create time gt; ltMsgType gt lt![CDATA[% s]] gt; lt/msg type gt; lt内容 gt lt![CDATA[% s]] gt; lt/Content gt; ltFuncFlag gt0 lt/func flag gt; lt/XML gt;";如果(!empty($ keyword)){ $ msgType = ;文本 ;$ contentStr = 欢迎来到微信世界!";$resultStr = sprintf($textTpl,$fromUsername,$toUsername,$time,$msgType,$ contentStr);echo $ resultStr} else { echo 输入一些东西...";}///////////////////////////////////////////////////////{ else { echo ;暂时没有信息!";退出;}}//log公共函数ZC日志($ errcode,$ errmsg){ $ this ->;returny = array();$ this - gt;退货[ # 39;错误代码 # 39;]= $ errcode;$ this - gt;退货[ # 39;errmsg # 39]= $ errmsg;$ this - gt;退货[ # 39;errtime # 39] =日期( y-m-d H:I:s ;,time());$ log file = fopen( ;日志文件_ 。日期( Ymd ,时间())。"。txt , a+ ;);$ txt = JSON _ encode($ this - gt;退货)。"\ n ;fwrite($logfile,$ txt);fclose($ log file);//return $ this - gt;退货;} }3.【代码】微信运营类-更新了自定义菜单部分。

lt马鞭PHP/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *作者Kyler You ltQQ:2444756311 gt;* @链接http://mp.weixin.qq.com/wiki/home/index.html * @ 2 . 0 . 1版* @使用$ wx API = new wx API();* @包微信API接口会陆续持续更新* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ;;//const app secret = ;";const appId = ";const appSecret = ";//const MC hid = ;";//商户号//const private key = " ;;//私钥public $ parameters = array();public _ _ construct(){ }/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *。 * * * *返回微信上指定的JSON * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */public function WxHttpRequest($ URL,* curl_setopt($curl,CURLOPT_URL,$ URL); curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,FALSE);curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,FALSE);如果(!empty($ data)){ curl _ setopt($ curl,CURLOPT_POST,1);curl_setopt($curl,CURLOPT_POSTFIELDS,$ data);} curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);$ output = curl _ exec($ curl);curl _ close($ curl);返回$ output}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *微信带证书提交数据-微信红包使用* * * *公共函数wxHttpsRequestPem($url,$vars,$second=30,$ a header = array()){ $ ch = curl _ init();//timeout curl _ setopt ($ ch,curl opt _ timeout,$ second);curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//在这里设置代理,如果有的话//curl _ setopt ($ ch,curl opt _ proxy, # 39;10.206.30.98');//curl_setopt($ch,CURLOPT_PROXYPORT,8080);curl_setopt($ch,CURLOPT_URL,$ URL);curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);//需要选择以下两种方法中的一种。//第一个方法,cert和key属于两个。pem文件。//默认格式为PEM,curl _ setopt ($ ch,curl opt _ sslcerttype, # 39;PEM # 39);curl_setopt($ch,CURLOPT_SSLCERT,getcwd()。'/API client _ cert . PEM # 39;);//默认格式为PEM,curl _ setopt ($ ch,curl opt _ sslkeytype, # 39;PEM # 39);curl_setopt($ch,CURLOPT_SSLKEY,getcwd()。'/API client _ key . PEM # 39;);curl_setopt($ch,CURLOPT_CAINFO, # 39;PEM # 39);curl_setopt($ch,CURLOPT_CAINFO,getcwd()。'/rootca . PEM # 39;);//第二种方式,两个文件合二为一。pem文件//curl _ setopt ($ ch,curl opt _ sslcert,getcwd()。# 39;/all . PEM # 39;);if( count($aHeader)>= 1 ){ curl_setopt($ch,CURLOPT_HTTPHEADER,$ a header);} curl_setopt($ch,CURLOPT_POST,1);curl_setopt($ch,CURLOPT_POSTFIELDS,$ vars);$ data = curl _ exec($ ch);if($ data){ curl _ close($ ch);返回$ data} else { $ error = curl _ errno($ ch);回声 调用失败,错误代码:$ error \ n ;curl _ close($ ch);返回false} }/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */公共函数wxAccessToken($appId = NULL,$ app secret = NULL){ $ appId = is _ NULL($ appId)?self::appId:$ appId;$appSecret = is_null($appSecret)?self::app secret:$ app secret;$ data = JSON _ decode(file _ get _ contents( ;access _ token.json ));if($data - gt;expire _ time lttime()) { //echo $appId,$ appSecret$ url = https://api.weixin.qq.com/cgi-bin/token?格兰特类型=客户证书 appid = 。$appId。" secret = 。$ appSecret$ result = $ this - gt;wxHttpsRequest($ URL);//print _ r($ result);$jsoninfo = json_decode($result,true);$ access _ token = $ JSON info[ ;访问令牌 ];if($ access _ token){ $ data - gt;expire _ time = time()+7000;$data->access _ token = $ access _ token$ FP = fopen( ;access _ token.json , w );fwrite($fp,JSON _ encode($ data));fclose($ FP);} } else { $ access _ token = $ data - gt;access _ token} return $ access _ token}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */公共函数wxjsapitticket($ appId = NULL,$ app secret = NULL){ $ appId = is _ NULL($ appId)?self::appId:$ appId;$appSecret = is_null($appSecret)?self::app secret:$ app secret;$ data = JSON _ decode(file _ get _ contents( ;jsapi _ ticket.json ));if($data - gt;expire _ time lttime()){ $ URL = ;https://api.weixin.qq.com/cgi-bin/ticket/getticket?类型= jsapi access _ token = 。$ this - gt;wxAccessToken();$ result = $ this - gt;wxHttpsRequest($ URL);$jsoninfo = json_decode($result,true);$ ticket = $ JSON info[ # 39;门票 # 39;];if($ ticket){ $ data - gt;expire _ time = time()+7000;$data->jsapi _ ticket = $ ticket$ FP = fopen( ;jsapi _ ticket.json , w );fwrite($fp,JSON _ encode($ data));fclose($ FP);} } else { $ ticket = $ data - gt;jsapi _ ticket} return $ ticket}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *微信通过OPENID获取用户信息, 返回数组* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */public function WX GetUser($ OpenID){ wxAccessToken(); $ url = https://api.weixin.qq.com/cgi-bin/user/info?访问令牌= 。$wxAccessToken。" openid = 。$openId。" lang = zh _ CN ;$ result = $ this - gt;wxHttpsRequest($ URL);$jsoninfo = json_decode($result,true);返回$ jsoninfo}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *公共函数wxqr code ticket($ JSON data){ $ wxAccessToken = $ this - gt;wxAccessToken();$ url = https://api.weixin.qq.com/cgi-bin/qrcode/create?访问令牌= 。$ wxAccessToken$ result = $ this - gt;wxHttpsRequest($url,$ JSON data);返回$ result}公共函数wxqr code($ ticket){ $ URL = ;https://mp.weixin.qq.com/cgi-bin/showqrcode?机票= 。urlencode($ ticket);返回$ url}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *公共函数wxSetSend($touser,$template_id,$url,$data,$ topcolor = # 39# 7B68EE # 39){ $ template = array( # 39;touser # 39= gt$touser, # 39;template _ id # 39= gt$template_id, # 39;网址 # 39;= gt$url, # 39;topcolor # 39= gt$topcolor, # 39;数据 # 39;= gt$ data);$ JSON data = JSON _ encode($ template);$ result = $ this - gt;wxSendTemplate($ JSON data);返回$ result}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *微信设置OAUTH跳转URL并返回字符串信息-。您只能获得OpenID * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */public function WXOAUTHBase($ redirection ;,$ appId = NULL){ $ appId = is _ NULL($ appId)?self::appId:$ appId;$ url = https://open.weixin.qq.com/connect/oauth2/authorize? appid = ;。$appId。" redirect _ uri = 。$redirectUrl。" 代码 scope = snsapi _ base state = 。$州。"#微信_重定向 ;返回$ url}返回字符串信息- SCOPE = snsapi_userinfo //获取用户的完整信息* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ;,$ appId = NULL){ $ appId = is _ NULL($ appId)?self::appId:$ appId;$ url = https://open.weixin.qq.com/connect/oauth2/authorize? appid = ;。$appId。" redirect _ uri = 。$redirectUrl。" 代码 scope = snsapi _ userinfo state = 。$州。"#微信_重定向 ;返回$ url}地点: 。$ URL);}公共函数wxOauthAccessToken($code,$appId = NULL,$ app secret = NULL){ $ appId = is _ NULL($ appId)?self::appId:$ appId;$appSecret = is_null($appSecret)?self::app secret:$ app secret;$ url = https://api.weixin.qq.com/sns/oauth2/access_token? appid = ;。$appId。" secret = 。$appSecret。" code = 。$code。" grant _ type = authorization _ code ;$ result = $ this - gt;wxHttpsRequest($ URL);//print _ r($ result);$jsoninfo = json_decode($result,true);//$ access _ token = $ JSON info[ ;访问令牌 ];返回$ jsoninfo}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */公共函数wxOauthUser($OauthAT,$ openId){ $ URL = ;https://api.weixin.qq.com/sns/userinfo?访问令牌= 。$OauthAT。" openid = 。$openId。" lang = zh _ CN ;$ result = $ this - gt;wxHttpsRequest($ URL);$jsoninfo = json_decode($result,true);返回$ jsoninfo}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *创建自定义菜单公共函数wxMenuCreate($ JSON data){ $ wxAccessToken = $ this - gt;wxAccessToken();$ url = https://api.weixin.qq.com/cgi-bin/menu/create?访问令牌= 。$ wxAccessToken$ result = $ this - gt;wxHttpsRequest($url,$ JSON data);$jsoninfo = json_decode($result,true);返回$ jsoninfo}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *公共函数wx menuget(){ $ wxAccessToken = $ this - gt;wxAccessToken();$ url = https://api.weixin.qq.com/cgi-bin/menu/get?访问令牌= 。$ wxAccessToken$ result = $ this - gt;wxHttpsRequest($ URL);$jsoninfo = json_decode($result,true);返回$ jsoninfo}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *删除自定义菜单公共函数wxmenu Delete(){ $ wxAccessToken = $ this - gt;wxAccessToken();$ url = https://api.weixin.qq.com/cgi-bin/menu/delete?访问令牌= 。$ wxAccessToken$ result = $ this - gt;wxHttpsRequest($ URL);$jsoninfo = json_decode($result,true);返回$ jsoninfo}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *公共函数wxMenuGetInfo(){ $ wxAccessToken = $ this - gt;wxAccessToken();$ url = https://API . weixin . QQ . com/CGI -bin/get _ current _ self menu _ info?access _ token = 。$ wxAccessToken$ result = $ this - gt;wxHttpsRequest($ URL);$jsoninfo = json_decode($result,true);返回$ jsoninfo} *********/公共函数wxnon centr($ length = 16,$ type = FALSE){ $ chars = ;abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz 0123456789 ;;$ str = ";for($ I = 0;$ i lt$长度;$i++) { $str。= substr($chars,mt_rand(0,strlen($chars) - 1),1);} if($ type = = TRUE){ return strto upper(MD5(time()。$ str));} else { return $ str} ***************/公共函数wxMchBillno($ MC hid = NULL){ if(is _ NULL($ MC hid)){ if(self::MC hid = = ;"| | is _ null(self::MC hid)){ $ MC hid = time();} else { $ MC hid = self::MC hid;} } else { $ MC hid = substr(add slashes($ MC hid),0,10);}返回日期( Ymd ,时间())。时间()。$ mchid} *************/公共函数wxSetParam($ parameters){ if(is _ array($ parameters) ; !empty($ parameters)){ $ this - gt;parameters = $ parametersreturn $ this - gt;参数;} else{返回数组();} * * * * * * * * * * * * * * * * * * */公共函数wxFormatArray($parameters = NULL,$ urlencode = FALSE){ if(is _ NULL($ parameters)){ $ parameters = $ this - gt;参数;} $ restr = ";//初始化一个空ksort($ parameters);//排序参数foreach($ parameters as $ k = > >;$v){//循环定制参数if (null!= $ v "null != $ v "签名 != $k) {if($urlencode){//如果参数需要增加URL加密,就会增加;如果没有,就不需要$ v = urlencode($ v);} $restr。= $ k。 ;= 。v . ";//返回完整的字符串}} if (strlen ($ restr) >: 0) {//如果有数据,最后的“”Delete $ restr = substr($ restr,0,strlen($ restr)-1);} return $ restr//Return string }/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *微信MD5 * * * * * * * * * * * * * * * * * * * * * * * * * *公共函数wxMd5Sign($content,$ private key){ try { if(is _ null($ private key)){ throw new Exception( ;财付通签名密钥不能为空!");} if (is_null($content)) {抛出新异常( 财付通签名内容不能为空”);} $signStr = $content。" key = 。$ privatekey返回strto upper(MD5($ signStr));} catch(异常$ e){ die($ E- gt;getMessage());} }/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *微信Sha1签名生成器-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */公共函数wxsha1 sign($content){ try { if(is _ null($content)){ throw new Exception( ;签名内容不能为空”);}///$ signStr = $ content;返回sha1($ content);} catch(异常$ e){ die($ E- gt;getMessage());} }/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *微信jsApi集成方法-* * * * * * * * * * * * * * * * * * * * * * */公共函数wxjsapi package(){ $ jsApi _ ticket = $ this - gt;wxjsapi ticket();//注意,URL必须动态获取,不能硬编码。$protocol =(!空($ _ SERVER[ # 39;HTTPS # 39;]) ; $ _服务器[ # 39;HTTPS # 39;] !== '关 # 39;| | $ _服务器[ # 39;服务器端口 # 39;] == 443) ?"https:// ;: http:// ;;$url = $protocol。$ _ SERVER[ ;HTTP _ HOST ].$ _ SERVER[ ;请求_ URI ;];$ timest = time();$ non centr = $ this - gt;wxNonceStr();$ sign package = array( ;jsapi _ ticket = gt$jsapi_ticket, 非中心 = gt$ nonceStr, 时间戳 = gt$timest, url = gt$ URL);//这里参数的顺序要按照键值$ raw string = " jsapi _ ticket = $ jsapi _ ticket ;noncestr = $ nonceStr 时间戳= $时间戳 url = $ url ;//$ raw string = $ this - gt;wx format array($ sign package);$ signature = $ this - gt;wx sha 1 sign($ raw string);$ sign package[ # 39;签名 # 39;]= $ signature;$ sign package[ # 39;rawString # 39]= $ raw string;$ sign package[ # 39;appId # 39]= self::appId;返回$ signPackage}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */公共函数wxArrayToXml($parameters = NULL){ if(is _ NULL($parameters)){$parameters =$this - gt;参数;}如果(!is _ array($ parameters)| | empty($ parameters)){ die( ;参数不是数组,无法解析。);} $ xml = ltxml gt";foreach($ arr as $ key = gt;$ val){ if(is _ numeric($ val)){ $ XML。= lt"。$key。" gt"。$瓦尔。" lt/ ;。$key。" gt";} else $xml。= lt"。$key。" gt lt![CDATA[ ;。$瓦尔。"]] gt; lt/ ;。$key。" gt";} $xml。= lt/XML gt;";返回$ xml}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *微信卡券:上传LOGO - *************/公共函数wxCardUpdateImg(){ $ wxAccessToken = $ this - gt;wxAccessToken();//$ data[ # 39;访问令牌 # 39;]= $ wxAccessToken;$ data[ # 39;缓冲 # 39;] = '@ D:\ \ workspace \ \ htdocs \ \ yky _ test \ \ logo . jpg # 39;;$ url = https://api.weixin.qq.com/cgi-bin/media/uploadimg?访问令牌= 。$ wxAccessToken$ result = $ this - gt;wxHttpsRequest($url,$ data);$jsoninfo = json_decode($result,true);返回$ jsoninfo//array(1){[ ;url ]= gt;字符串(121) ;http://mm biz . qpic . cn/mm biz/ibuxphqexepntw 4 atkyias 1c F3 ztk iars 9 pfpz f1 k 5 icv xd 7 xw0k xuaxhdzked 9 micc mcn 0 ctjfw 6 tnm 93 mia afrq/0 ;} */public function wxCardColor(){ $ wxAccessToken = $ this - gt;wxAccessToken();$ url = https://api.weixin.qq.com/card/getcolors?访问令牌= 。$ wxAccessToken$ result = $ this - gt;wxHttpsRequest($ URL);$jsoninfo = json_decode($result,true);返回$ jsoninfo}公共函数wxCardCreated($ JSON data){ $ wxAccessToken = $ this - gt;wxAccessToken();$ url = https://api.weixin.qq.com/card/create?访问令牌= 。$ wxAccessToken$ result = $ this - gt;wxHttpsRequest($url,$ JSON data);$jsoninfo = json_decode($result,true);返回$ jsoninfo}/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *微信卡券:JSAPI卡券* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */公共函数wxCardPackage($ cardId){ $ timest = time();$ API _ ticket = $ this - gt;wxjsapi ticket();$ cardId = $ cardId$arrays = array($api_ticket,$timest,$ cardId);sort($ arrays);$string = sha1(内爆( ",$ arrays));$ result array[ # 39;card _ id # 39]= $ cardId;$ result array[ # 39;card _ ext # 39]= array();$ result array[ # 39;card _ ext # 39]['openid # 39] = 'oomn 4s 9 miwqhsnnvpn 0 dbtu 23 toa # 39;;$ result array[ # 39;card _ ext # 39]['时间戳 # 39;]= $ timest;$ result array[ # 39;card _ ext # 39]['签名 # 39;]= $ string;返回$ resultArray} }4.【代码】微信JSAPI

lt马鞭php require _ once # 39lib . Inc . PHP # 39;;$ wx = new wx API();//获取openid //if(!isset($ _ GET[ # 39;代码 # 39;])){//header( ;位置:https://open . weixin . QQ . com/connect/oauth 2/authorize?appid = 。WxApi::appId。" redirect _ uri = http:// ;。$ _服务器[ # 39;服务器名称 # 39;].$ _服务器[ # 39;PHP _ SELF # 39]." 代码 scope = snsapi _ base state = 1 #微信_重定向 );//}//else {//$ CODE = $ _ GET[ # 39;代码 # 39;];//$ Info = $ wx- gt;wxOauthAccessToken($ CODE);//print _ r($ Info);//$ openId = $ Info[ # 39;openid # 39];//}/////////////////////////////////////////$ sign package = $ wx- gt;wxjsapi package();//print _ r($ sign package);$ kqInfo = $ wx- gt;wxCardPackage( ;");$ listInfo = $ wx- gt;wxcardlist package();马鞭 gt lthtml gt lthead gt lttitle gtJSAPI接口测试

$ kqinfo = array( ;卡片 = gtarray());$ kqinfo[ # 39;卡 # 39;]['卡_类型 # 39;] = '通用_优惠券 # 39;;$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;] =数组( # 39;base _ info # 39= gtarray(), # 39;default _ detail # 39= gtarray());$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['base _ info # 39]['logo _ url # 39] = '网址 # 39;;$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['base _ info # 39]['code _ type # 39] = 'CODE _ TYPE _ QRCODE # 39;$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['base _ info # 39]['brand _ name # 39] = '';$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['base _ info # 39]['标题 # 39;] = '测试卡优惠券 # 39;;$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['base _ info # 39]['color # 39] = 'Color030 # 39;$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['base _ info # 39]['注意 # 39;] = '测试测试 # 39;;$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['base _ info # 39]['描述 # 39;] = '这是优惠券 # 39;;$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['base _ info # 39]['日期信息 # 39;]['类型 # 39;] = 1;$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['base _ info # 39]['日期信息 # 39;]['begin _ timest # 39]= time();$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['base _ info # 39]['日期信息 # 39;]['end _ timest # 39]= time()+100 * 24 * 3600;$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['base _ info # 39]['sku # 39]['数量 # 39;] = 100000;$ kqinfo[ # 39;卡 # 39;]['通用_优惠券 # 39;]['default _ detail # 39] = '测试数据\n测试数据\n测试数据 # 39;;//var _ dump($ kqinfo);//$ kqinfo = JSON _ encode($ kqinfo);$ kqinfo = C::en JSON($ kqinfo);//print _ r($ kqinfo);//$ result data = $ wx- gt;wxCardCreated($ kqinfo);相关建议:

php Restful api示例

以上是微信API接口的细节。更多请关注主机参考其他相关文章!

这几篇文章你可能也喜欢:

本文由主机参考刊发,转载请注明:微信api接口(微信API接口地址) https://zhujicankao.com/80480.html

【腾讯云】领8888元采购礼包,抢爆款云服务器 每月 9元起,个人开发者加享折上折!
打赏
转载请注明原文链接:主机参考 » 微信api接口(微信API接口地址)
主机参考仅做资料收集,不对商家任何信息及交易做信用担保,购买前请注意风险,有交易纠纷请自行解决!请查阅:特别声明

评论 抢沙发

评论前必须登录!