午夜91福利视频,午夜成人在线观看,午夜在线视频免费观看,午夜福利短视频,精品午夜成人免费视频APP

小程序模板網

微信小程序卡券開發(親測)

發布時間:2017-12-16 14:57 所屬欄目:小程序開發教程

提示:小程(cheng)序卡券和公(gong)眾(zhong)平(ping)臺調(diao)用基本一(yi)致,請(qing)先查看公(gong)眾(zhong)平(ping)臺卡券文檔 一(yi)、公(gong)眾(zhong)帳號/小程(cheng)序綁定 由于(yu)微信(xin)卡券用的(de)是一(yi)套邏(luo)輯。所以小程(cheng)序需要先和公(gong)眾(zhong)賬號綁定,才(cai)能在(zai)小程(cheng)序中調(diao)起公(gong)眾(zhong)平(ping)臺卡券 登錄微信(xin)公(gong)眾(zhong)平(ping)臺:h ...

 
 
 
提示:小程序卡券和公眾平臺調用基本一致,請先查看公眾平臺卡券文檔

一、公眾帳號/小程序綁定
由于微信卡券用的是一套邏輯。所以小程序需要先和公眾賬號綁定,才能在小程序中調起公眾平臺卡券
登錄微信公眾平臺://open.weixin.qq.com/ 進行綁定操作
QQ截圖20170603110606.png

二、公眾號卡券添加小程序字段
更改卡券信息接口://api.weixin.qq.com/card/update?access_token=TOKEN
文檔參考://mp.weixin.qq.com/cgi-bin ... ng=zh_CN&platform=2


[PHP] 

							
  1. $access_token = 'Yn6h-PM679IXWtndisSKGtxWHV3rHpIl9IrUVFgE96m4aKbhyVDiG34OuOUGs_SIIceQSplwLWWexURWiuXGyTkaYXU8pFW-goveJ8XQJvpSU1KX9UnUssssssssssQhAAAGWZ';
  2.  
  3. $post = '{
  4.  
  5. "card_id":"cccccccccccccccccc-dw",
  6.  
  7. "gift": {
  8.  
  9. "base_info": {
  10.  
  11. "custom_url_name": "小程序(xu)",
  12.  
  13. "custom_url": "//www.qq.com",
  14.  
  15. "custom_app_brand_user_name": "gh_aaaaaaaaaaa@app",
  16.  
  17. "custom_app_brand_pass":"pages/index/index",
  18.  
  19. "custom_url_sub_title": "點擊進入",
  20.  
  21. "promotion_url_name": "更多信息",
  22.  
  23. "promotion_url": "//www.qq.com",
  24.  
  25. "promotion_app_brand_user_name": "gh_aaaaaaaaaaa@app",
  26.  
  27. "promotion_app_brand_pass":"pages/index/index"
  28.  
  29. }
  30.  
  31. }
  32.  
  33. }';
  34.  
  35. $url = "//api.weixin.qq.com/card/update?access_token={$access_token}";
  36.  
  37.  
  38.  
  39. $curl = curl_init();
  40.  
  41. curl_setopt($curl, CURLOPT_URL, $url);
  42.  
  43. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
  44.  
  45. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
  46.  
  47. if (!empty($post)) {
  48.  
  49. curl_setopt($curl, CURLOPT_POST, 1);
  50.  
  51. curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
  52.  
  53. }
  54.  
  55. curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
  56.  
  57. $output = curl_exec($curl);
  58.  
  59. curl_close($curl);
  60.  
  61.  
  62.  
  63. var_dump($output);
  64.  
  65. die();
三、卡券簽名 卡券簽名與公眾號卡券簽名一致,注意使用api_ticket簽名 參考文檔://mp.weixin.qq.com/wiki?ac ... 52296&highline=card|%26amp%3Bcardext#fl4 卡券簽名驗證工具://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] 

							
  1. let cardExt='{"timestamp":"'+res.data[0].timestamp+'","signature":"'+res.data[0].signature+'","nonce_str":"'+res.data[0].nonce_str+'"}'
  2.  
  3. wx.addCard({
  4.  
  5. cardList: [
  6.  
  7. {
  8.  
  9. cardId: res.data[0].cardId,
  10.  
  11. cardExt: cardExt
  12.  
  13. }
  14.  
  15. ],
  16.  
  17. success: function(res) {
  18.  
  19. console.log(res)
  20.  
  21. }
  22.  
  23. })
  24.  
領取卡券后返回數據格式 QQ截圖20170603143325.png


易優(you)小(xiao)程(cheng)序(企業版)+靈(ling)活api+前(qian)后代(dai)碼(ma)開(kai)源 碼云倉(cang)庫:
本文地址://www.jinyoudianli.com/wxmini/doc/course/18180.html 復制鏈接 如需定(ding)制請聯系易優客服(fu)咨(zi)詢(xun):

工作日 8:30-12:00 14:30-18:00
周六及部分節假日提供值班服務

易(yi)小優(you)
轉人工 ×