首頁 >php教程 >php手册 >微信卡卷测试代码

微信卡卷测试代码

WBOY
WBOY原創
2016-06-07 11:37:581482瀏覽

微信卡卷测试代码
创建卡卷:public function createcard(){//新建卡卷<br>     $appid=C('APPID');<br>          $appsecret=C('SCRETID');<br>         $asstonek = $this->get_token($appid,$appsecret);<br>         $url = "https://api.weixin.qq.com/card/create?access_token=".$asstonek;<br>         $pjson ='{ "card": {<br> "card_type": "GROUPON",<br> "groupon": {<br> "base_info": {<br> "logo_url":<br> "http://mmbiz.qpic.cn/mmbiz/ibkgH5qOticpLRCYTKmibPW028nOv2YYg42UsK8MWV5fVLRUUTrNyrg3nJgxThaP9tNg1JZXHk88FdLqxmmNq4CHg/0?wx_fmt=jpeg",<br> "brand_name":"海底捞123",<br> "code_type":" CODE_TYPE_TEXT ",<br> "title": "132 元双人火锅套餐",<br> "sub_title": "",<br> "color": "Color010",<br> "notice": "使用时向服务员出示此券",<br> "service_phone": "020-88888888",<br> "description": "不可与其他优惠同享\n 如需团购券发票, 请在消费时向商户提出\n 店内均可<br> 使用,仅限堂食\n 餐前不可打包,餐后未吃完,可打包\n 本团购券不限人数,建议 2 人使用,超过建议人<br> 数须另收酱料费 5 元/位\n 本单谢绝自带酒水饮料",<br> "date_info": {<br> "type": 2,<br> "fixed_term": 30,<br> "fixed_begin_term": 0<br> },<br> "sku": {<br> "quantity": 500000<br> },<br> "get_limit": 3,<br> "use_custom_code": false,<br> "bind_openid": false,<br> "can_share": true,<br> "can_give_friend": true,<br> "location_id_list" : [123, 12321, 345345],<br> "custom_url_name": "立即使用",<br> "custom_url": "http://www.qq.com",<br> "custom_url_sub_title": "6 个汉字 tips",<br> "promotion_url_name": "更多优惠",<br> "promotion_url": "http://www.qq.com",<br> "source": "大众点评"<br> },<br> "deal_detail": "以下锅底 2 选 1(有菌王锅、麻辣锅、大骨锅、番茄锅、清补凉锅、酸菜鱼锅可<br> 选):\n 大锅 1 份 12 元\n 小锅 2 份 16 元\n 以下菜品 2 选 1\n 特级肥牛 1 份 30 元\n 洞庭鮰鱼卷 1 份<br> 20 元\n 其他\n 鲜菇猪肉滑 1 份 18 元\n 金针菇 1 份 16 元\n 黑木耳 1 份 9 元\n 娃娃菜 1 份 8 元\n 冬<br> 瓜 1 份 6 元\n 火锅面 2 个 6 元\n 欢乐畅饮 2 位 12 元\n 自助酱料 2 位 10 元"}<br> }<br> }';<br>  <br>  <br> $re3 = $this->curlp($url,$pjson);<br>         $re3arr = json_decode($re3,true);<br>         dump($re3arr);<br>      <br>     }卡卷领取测试:(二维码)public function tcard(){//卡卷测试<br>     header ( "Content-Type: text/html; charset=UTF-8" );<br>      <br>      <br>         $appid=C('APPID');<br>          $appsecret=C('SCRETID');<br>         $asstonek = $this->get_token($appid,$appsecret);     <br>         $ticket = $this->get_card_ticket($asstonek);<br>         dump($asstonek);<br>         dump($ticket);<br>          <br>          <br>         /*  获取卡卷列表<br>         $url = "https://api.weixin.qq.com/card/batchget?access_token=".$asstonek;<br>         $jsondata = '{"offset":0,"count":10}';<br>         $re = $this->curlp($url,$jsondata);<br>         dump($re);<br>         */<br>          <br>         //  获取卡卷详情<br>         $url3 = "https://api.weixin.qq.com/card/get?access_token=".$asstonek;<br>         $getcardinfo = '{<br> "card_id":"pYKCus2uC2fwIf3STA-agJ_XhqfI"<br> }';<br>  <br>     $re3 = $this->curlp($url3,$getcardinfo);<br>         $re3arr = json_decode($re3,true);<br>         dump($re3arr);<br>         //  status =  CARD_STATUS_VERIFY_OK  卡卷审核通过<br>         //  获取卡卷详情<br>          <br>          <br>         $fcardjson = '{<br> "action_name": "QR_CARD",<br> "action_info": {<br> "card": {<br> "card_id": "pYKCus2uC2fwIf3STA-agJ_XhqfI",<br> "is_unique_code": false ,<br> }<br> }<br> }';<br>  <br> $url2 = "https://api.weixin.qq.com/card/qrcode/create?access_token=".$asstonek;<br> $re2 = $this->curlp($url2,$fcardjson);<br> $re2arr = json_decode($re2,true);<br> $ewmticket = $re2arr['ticket'];<br> if($re2arr['errmsg']!='ok') exit($re2arr['errmsg']);<br> dump($re2arr);<br> echo '<img alt="微信卡卷测试代码" >';<br>          <br>          <br>          <br>     }卡卷投放(领取):html5 js apipublic function get_h5_card($data=array()){<br>     $appid=$this->appid;<br>     $appsecret=$this->appsecret;<br>     $asstonek = $this->get_token($appid,$appsecret);     <br>     $ticket = $this->get_card_ticket($asstonek);<br>     $data['api_ticket']=$ticket;<br>     $data['timestamp']=time();<br>     $data['signature'] = self::getSign($data);  <br>     //echo $ticket;<br>     $data2['card_id']=$data['card_id'];<br>     unset($data['api_ticket']);<br>     unset($data['card_id']);<br>     $data2['card_ext']=json_encode($data);<br>     return $data2;<br>     dump($data);<br> }   <br>      <br>  <br> public function tcard1(){//html5 js api 卡卷投放<br>         $card = new \Org\Util\Card('wx37445*******3ae8','6854f901**********4f9a3');<br>         $cardid = 'pYKCus4Tmp_sBh6eiqfG-hN_ySzc';<br>         $data['card_id']=$cardid;<br>         $data['code']='';<br>         $data['openid']='';<br>         $data2 = $card->get_h5_card($data);<br>         $this->assign('carddata',json_encode($data2));<br>         //dump(($data2));<br>         $this->siteDisplay ( 'card' );已封装成类,可随意调用。需要完整代码请联系关注以下公众号联系:

微信卡卷测试代码

另外还有微信红包代码封装成类,可直接调用。需要请联系上面微信号

原文地址: http://shanmao.me/weixin/wei-xin-ka-juan-ce-shi-dai-ma

AD:真正免费,域名+虚机+企业邮箱=0元

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn