提示:小程序卡券和公众平台调用基本一致,请先查看公众平台卡券文档 一、公众帐号/小程序绑定 由于微信卡券用的是一套逻辑。所以小程序需要先和公众账号绑定,才能在小程序中调起公众平台卡券 登录微信公众平台:h ...
$access_token = 'Yn6h-PM679IXWtndisSKGtxWHV3rHpIl9IrUVFgE96m4aKbhyVDiG34OuOUGs_SIIceQSplwLWWexURWiuXGyTkaYXU8pFW-goveJ8XQJvpSU1KX9UnUssssssssssQhAAAGWZ';
$post = '{
"card_id":"cccccccccccccccccc-dw",
"gift": {
"base_info": {
"custom_url_name": "小程序",
"custom_url": "http://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": "http://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();
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)
}
})