摘要:本文将带你了解微信小程序开发之卡券开发(亲测),希望本文对大家学微信有所帮助。
本文将带你了解微信小程序开发之卡券开发(亲测),希望本文对大家学微信有所帮助。
提示:小程序卡券和公众平台调用基本一致,请先查看公众平台卡券文档
一、公众帐号/小程序绑定
由于微信卡券用的是一套逻辑。所以小程序需要先和公众账号绑定,才能在小程序中调起公众平台卡券
登录微信公众平台:https://open.weixin.qq.com/ 进行绑定操作
二、公众号卡券添加小程序字段
更改卡券信息接口:https://api.weixin.qq.com/card/update?access_token=TOKEN
文档参考:https://mp.weixin.qq.com/cgi-bin ... ng=zh_CN&platform=2
[PHP] $access_token = 'Yn6h-PM679IXWtndisSKGtxWHV3rHpIl9IrUVFgE96m4aKbhyVDiG34OuOUGs_SIIceQSplwLWWexURWiuXGyTkaYXU8pFW-goveJ8XQJvpSU1KX9UnUssssssssssQhAAAGWZ';$post = '{ "card_id":"cccccccccccccccccc-dw", "gift": { "base_info": { "custom_url_name": "小程序", "custom_url": "//www.qq.com", "custom_app_brand_user_name": "gh_aaaaaaaaaaa@app", "custom_app_brand_pass":"pages/index/index", "custom_url_sub_title": "点击进入", "promotion_url_name": "更多信息", "promotion_url": "//www.qq.com", "promotion_app_brand_user_name": "gh_aaaaaaaaaaa@app", "promotion_app_brand_pass":"pages/index/index" } } }';$url = "https://api.weixin.qq.com/card/update?access_token={$access_token}";$curl = curl_init();curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);if (!empty($post)) { curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $post);}curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);$output = curl_exec($curl);curl_close($curl);var_dump($output);die();
三、卡券签名
卡券签名与公众号卡券签名一致,注意使用api_ticket签名
参考文档:https://mp.weixin.qq.com/wiki?ac ... 52296&highline=card|%26amp%3Bcardext#fl4
卡券签名验证工具:https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=cardsign
四、小程序调用
注意点:
1、卡券字段use_custom_code填写为false时,code字段不用加到cardExt
2、卡券字段bind_openid填写为false是,openid字段不用加到cardExt
3、当签名时使用nonce_str字段签名时,nonce_str字段需要加到cardExt
[JavaScript] let cardExt='{"timestamp":"'+res.data[0].timestamp+'","signature":"'+res.data[0].signature+'","nonce_str":"'+res.data[0].nonce_str+'"}' wx.addCard({ cardList: [ { cardId: res.data[0].cardId, cardExt: cardExt } ], success: function(res) { console.log(res) } })
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之微信频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号