WeChat card volume test code

Source: Internet
Author: User
Provides various official and user-released code examples. For code reference, you are welcome to exchange the learning card volume test code.
Create a card volume: Public function createcard () {// create a card volume
$ Appid = C ('appid ');
$ Appsecret = C ('scretid ');
$ Asstonek = $ this-> get_token ($ appid, $ appsecret );
$ Url = "https://api.weixin.qq.com/card/create? Access_token = ". $ asstonek;
$ Pjson = '{"card ":{
"Card_type": "GROUPON ",
"Groupon ":{
"Base_info ":{
"Logo_url ":
"Http://mmbiz.qpic.cn/mmbiz/ibkgH5qOticpLRCYTKmibPW028nOv2YYg42UsK8MWV5fVLRUUTrNyrg3nJgxThaP9tNg1JZXHk88FdLqxmmNq4CHg/0? Wx_fmt = jpeg ",
"Brand_name": "haidilao 123 ",
"Code_type": "CODE_TYPE_TEXT ",
"Title": "132 yuan double hot pot package ",
"Sub_title ":"",
"Color": "Color010 ",
"Notice": "show this coupon to the waiter during use ",
"Service_phone": "020-88888888 ",
"Description": "cannot be shared with other discounts \ n if you need to purchase a coupon invoice, please submit it to the merchant at the time of consumption \ n in-store
Used. It can only be used for dine-in meals. \ n meals cannot be packed before meals, but not after meals. \ n group buying coupons can be packed for unlimited quantity. We recommend that you use them for two persons, exceeding the number of persons recommended.
Additional fee of soy sauce required: 5 RMB/bit \ n this ticket declined to bring your own drinks ",
"Date_info ":{
"Type": 2,
"Fixed_term": 30,
"Fixed_begin_term": 0
},
"Sku ":{
"Quantity": 500000
},
"Get_limit": 3,
"Use_custom_code": false,
"Bind_openid": false,
"Can_share": true,
"Can_give_friend": true,
"Location_id_list": [123,123 21, 345345],
"Custom_url_name": "Use now ",
"Custom_url": "http://www.qq.com ",
"Custom_url_sub_title": "6 Chinese tips ",
"Promotion_url_name": "More discounts ",
"Promotion_url": "http://www.qq.com ",
"Source": "public comment"
},
"Deal_detail"
(Selected): \ n large pot 1 copy 12 Yuan \ n small pot 2 Copy 16 Yuan \ n below dishes 2 choose 1 \ n super fat OX 1 copy 30 Yuan \ n Chamber catfish roll 1 copy
20 Yuan \ n others \ n fresh mushroom pork Slide 1 copy 18 yuan \ n Flammulina velutipes 1 copy 16 Yuan \ n black fungus 1 copy 9 Yuan \ n baby dishes 1 copy 8 Yuan \ n winter
Melon 1 copy 6 yuan \ n Hot Pot Noodles 2 6 yuan \ n happy drinks 2 12 Yuan \ n self-help sauce 2 10 yuan "}
}
}';


$ Re3 = $ this-> curlp ($ url, $ pjson );
$ Re3arr = json_decode ($ re3, true );
Dump ($ re3arr );

}
Card roll acquisition test: (QR code) Public function tcard () {// card volume test
Header ("Content-Type: text/html; charset = UTF-8 ");


$ Appid = C ('appid ');
$ Appsecret = C ('scretid ');
$ Asstonek = $ this-> get_token ($ appid, $ appsecret );
$ Ticket = $ this-> get_card_ticket ($ asstonek );
Dump ($ asstonek );
Dump ($ ticket );


/* Obtain the card volume list
$ Url = "https://api.weixin.qq.com/card/batchget? Access_token = ". $ asstonek;
$ Jsondata = '{"offset": 0, "count": 10 }';
$ Re = $ this-> curlp ($ url, $ jsondata );
Dump ($ re );
*/

// Obtain the card volume details
$ Url3 = "https://api.weixin.qq.com/card/get? Access_token = ". $ asstonek;
$ Getcardinfo = '{
"Card_id": "pYKCus2uC2fwIf3STA-agJ_XhqfI"
}';

$ Re3 = $ this-> curlp ($ url3, $ getcardinfo );
$ Re3arr = json_decode ($ re3, true );
Dump ($ re3arr );
// Status = CARD_STATUS_VERIFY_ OK the card volume is approved
// Obtain the card volume details


$ Fcardjson = '{
"Action_name": "QR_CARD ",
"Action_info ":{
"Card ":{
"Card_id": "pYKCus2uC2fwIf3STA-agJ_XhqfI ",
"Is_unique_code": false,
}
}
}';

$ Url2 = "https://api.weixin.qq.com/card/qrcode/create? Access_token = ". $ asstonek;
$ Re2 = $ this-> curlp ($ url2, $ fcardjson );
$ Re2arr = json_decode ($ re2, true );
$ Ewmticket = $ re2arr ['ticket'];
If ($ re2arr ['errmsg ']! = 'OK') exit ($ re2arr ['errmsg ']);
Dump ($ re2arr );
Echo '';



}
Card volume serving (receiving): html5 js api Public function get_h5_card ($ data = array ()){
$ Appid = $ this-> appid;
$ Appsecret = $ this-> appsecret;
$ Asstonek = $ this-> get_token ($ appid, $ appsecret );
$ Ticket = $ this-> get_card_ticket ($ asstonek );
$ Data ['api _ ticket '] = $ ticket;
$ Data ['timestamp'] = time ();
$ Data ['signature'] = self: getSign ($ data );
// Echo $ ticket;
$ Data2 ['Card _ id'] = $ data ['Card _ id'];
Unset ($ data ['api _ ticket ']);
Unset ($ data ['Card _ id']);
$ Data2 ['Card _ ext '] = json_encode ($ data );
Return $ data2;
Dump ($ data );
}


Public function tcard1 () {// html5 js api card volume serving
$ Card = new \ Org \ Util \ Card ('wx37445 ********* 3ae8', '6854f901 ************ 4f9a3 ');
$ Cardid = 'pykcus4tmp _ sBh6eiqfG-hN_ySzc ';
$ Data ['Card _ id'] = $ cardid;
$ Data ['code'] = '';
$ Data ['openid'] = '';
$ Data2 = $ card-> get_h5_card ($ data );
$ This-> assign ('carddata', json_encode ($ data2 ));
// Dump ($ data2 ));
$ This-> siteDisplay ('Card ');
It has been encapsulated into a class and can be called at will. For the complete code, contact the following public accounts:



In addition, the red packet code is encapsulated into a class and can be called directly. Please contact the above number if necessary

Address: http://shanmao.me/weixin/wei-xin-ka-juan-ce-shi-dai-ma

AD: truly free, domain name + VM + enterprise mailbox = 0 RMB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.