PHP version of the micro-credit card volume test code API

Source: Internet
Author: User
Tags ticket


To create a card volume:
Public Function Createcard () {//New 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": "Seabed fishing 123",
"Code_type": "Code_type_text",
"title": "132 yuan two-person hot pot Package",
"Sub_title": "",
"Color": "Color010",
"Notice": "Show this coupon to the waiter when using",
"Service_phone": "020-88888888",
"description": "Do not share with other offers \ n if you want to buy coupons invoices, please in the consumption of the shop to the store can be
Use, only for the hall food can not be packaged before the meal, after the meal has not finished, can pack \ n the number of purchase coupons, recommended 2 people to use, more than the recommended person
The number of additional sauce charge 5 yuan/bit \ n This list declined to bring their 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, 12321, 345345],
"Custom_url_name": "Use Now",
"Custom_url": "Http://www.qq.com",
"Custom_url_sub_title": "6 Chinese characters tips",
"Promotion_url_name": "More Concessions",
"Promotion_url": "Http://www.qq.com",
"Source": "Public comment"
},
"Deal_detail": "Pot Bottom 2 to choose 1 (Wang Yu, spicy pot, big bone pot, tomato pot, clear the pot, pickled cabbage fish pan can be
Select): \ n Big pot 1 12 yuan \ n Small pot 2 16 yuan \ n The following dishes 2 selected 1\n Super Fat cattle 1 30 yuan \ n dongting? Fish rolls 1
20 yuan \ Other Fresh mushroom pork slip 1 copies 18 yuan \ n Mushroom 1 16 yuan black fungus 1 part 9 yuan \ n Baby vegetables 1 8 yuan \ n Winter
Melon 1 copies 6 Yuan Pot Noodles 2 6 yuan \ n Happy drink 2 bit 12 yuan, self-help sauce 2 bit 10 Yuan}
}
}';


$re 3 = $this->CURLP ($url, $pjson);
$re 3arr = Json_decode ($re 3,true);
Dump ($re 3arr);

}
Card Volume Pick Test: (two-dimensional 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);


/* Get 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);
*/

Get the card volume details
$url 3 = "https://api.weixin.qq.com/card/get?access_token=". $asstonek;
$getcardinfo = ' {
"card_id": "Pykcus2uc2fwif3sta-agj_xhqfi"
}';

$re 3 = $this->CURLP ($url 3, $getcardinfo);
$re 3arr = Json_decode ($re 3,true);
Dump ($re 3arr);
Status = CARD_STATUS_VERIFY_OK Card Volume audit passed
Get the card volume details


$fcardjson = ' {
"Action_name": "Qr_card",
"Action_info": {
"Card": {
"card_id": "Pykcus2uc2fwif3sta-agj_xhqfi",
"Is_unique_code": false,
}
}
}';

$url 2 = "https://api.weixin.qq.com/card/qrcode/create?access_token=". $asstonek;
$re 2 = $this->CURLP ($url 2, $fcardjson);
$re 2arr = Json_decode ($re 2,true);
$ewmticket = $re 2arr[' ticket '];
if ($re 2arr[' errmsg ']!= ' OK ') exit ($re 2arr[' errmsg '));
Dump ($re 2arr);
Echo ' ';



}
Card volume launch (receive): 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;
$data 2[' card_id ']= $data [' card_id '];
unset ($data [' api_ticket ']);
unset ($data [' card_id ']);
$data 2[' Card_ext ']=json_encode ($data);
return $data 2;
Dump ($data);
}


Public Function Tcard1 () {//HTML5 JS API Card Volume launch
$card = new \org\util\card (' Wx37445*******3ae8 ', ' 6854f901**********4f9a3 ');
$cardid = ' PYKCUS4TMP_SBH6EIQFG-HN_YSZC ';
$data [' card_id ']= $cardid;
$data [' Code ']= '];
$data [' OpenID ']= '];
$data 2 = $card->get_h5_card ($data);
$this->assign (' Carddata ', Json_encode ($data 2));
Dump (($data 2));
$this->sitedisplay (' card ');
Need full card volume on the interface please Taobao contact me.

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.