php版本微信卡卷测试代码api

三月 06, 2019 | views
Comments 0

php版本微信卡卷测试代码api也是我们开发中的一个非常实用的插件了,下面我们来看看这篇php版本微信卡卷测试代码api例子,希望对各位有帮助。

创建卡卷:

  1. public function createcard(){//新建卡卷 
  2.     $appid=C('APPID'); 
  3.          $appsecret=C('SCRETID'); 
  4.         $asstonek = $this->get_token($appid,$appsecret); 
  5.         $url = "https://api.weixin.qq.com/card/create?access_token=".$asstonek
  6.         $pjson ='{ "card": { 
  7. "card_type""GROUPON"
  8. "groupon": { 
  9. "base_info": { 
  10. "logo_url"
  11. "http://mmbiz.qpic.cn/mmbiz/ibkgH5qOticpLRCYTKmibPW028nOv2YYg42UsK8MWV5fVLRUUTrNyrg3nJgxThaP9tNg1JZXHk88FdLqxmmNq4CHg/0?wx_fmt=jpeg"
  12. "brand_name":"海底捞123"
  13. "code_type":" CODE_TYPE_TEXT "
  14. "title""132 元双人火锅套餐"
  15. "sub_title"""
  16. "color""Color010"
  17. "notice""使用时向服务员出示此券"
  18. "service_phone""020-88888888"
  19. "description": "不可与其他优惠同享\n 如需团购券发票, 请在消费时向商户提出\n 店内均可 
  20. 使用,仅限堂食\n 餐前不可打包,餐后未吃完,可打包\n 本团购券不限人数,建议 2 人使用,超过建议人 
  21. 数须另收酱料费 5 元/位\n 本单谢绝自带酒水饮料", 
  22. "date_info": { 
  23. "type": 2, 
  24. "fixed_term": 30, 
  25. "fixed_begin_term": 0 
  26. }, 
  27. "sku": { 
  28. "quantity": 500000 
  29. }, 
  30. "get_limit": 3, 
  31. "use_custom_code": false, 
  32. "bind_openid": false, 
  33. "can_share": true, 
  34. "can_give_friend": true, 
  35. "location_id_list" : [123, 12321, 345345], 
  36. "custom_url_name""立即使用"
  37. "custom_url""http://www.qq.com"
  38. "custom_url_sub_title""6 个汉字 tips"
  39. "promotion_url_name""更多优惠"
  40. "promotion_url""http://www.qq.com"
  41. "source""大众点评" 
  42. }, 
  43. "deal_detail": "以下锅底 2 选 1(有菌王锅、麻辣锅、大骨锅、番茄锅、清补凉锅、酸菜鱼锅可 
  44. 选):\n 大锅 1 份 12 元\n 小锅 2 份 16 元\n 以下菜品 2 选 1\n 特级肥牛 1 份 30 元\n 洞庭?鱼卷 1 份 
  45. 20 元\n 其他\n 鲜菇猪肉滑 1 份 18 元\n 金针菇 1 份 16 元\n 黑木耳 1 份 9 元\n 娃娃菜 1 份 8 元\n 冬 
  46. 瓜 1 份 6 元\n 火锅面 2 个 6 元\n 欢乐畅饮 2 位 12 元\n 自助酱料 2 位 10 元"} //phpfensi.com 
  47. }'; 
  48.  
  49.  
  50. $re3 = $this->curlp($url,$pjson); 
  51.         $re3arr = json_decode($re3,true); 
  52.         dump($re3arr); 
  53.       
  54.     } 

卡卷领取测试:(二维码)

  1. public function tcard(){//卡卷测试 
  2.     header ( "Content-Type: text/html; charset=UTF-8" ); 
  3.       
  4.       
  5.         $appid=C('APPID'); 
  6.          $appsecret=C('SCRETID'); 
  7.         $asstonek = $this->get_token($appid,$appsecret);      
  8.         $ticket = $this->get_card_ticket($asstonek); 
  9.         dump($asstonek); 
  10.         dump($ticket); 
  11.           
  12.           
  13.         /*  获取卡卷列表 
  14.         $url = "https://api.weixin.qq.com/card/batchget?access_token=".$asstonek; 
  15.         $jsondata = '{"offset":0,"count":10}'; 
  16.         $re = $this->curlp($url,$jsondata); 
  17.         dump($re); 
  18.         */ 
  19.           
  20.         //  获取卡卷详情 
  21.         $url3 = "https://api.weixin.qq.com/card/get?access_token=".$asstonek
  22.         $getcardinfo = '{ 
  23. "card_id":"pYKCus2uC2fwIf3STA-agJ_XhqfI" 
  24. }'; 
  25.  
  26.     $re3 = $this->curlp($url3,$getcardinfo); 
  27.         $re3arr = json_decode($re3,true); 
  28.         dump($re3arr); 
  29.         //  status =  CARD_STATUS_VERIFY_OK  卡卷审核通过 
  30.         //  获取卡卷详情 
  31.           
  32.           
  33.         $fcardjson = '{ 
  34. "action_name""QR_CARD"
  35. "action_info": { 
  36. "card": { 
  37. "card_id""pYKCus2uC2fwIf3STA-agJ_XhqfI"
  38. "is_unique_code": false , 
  39. }'; 
  40.  
  41. $url2 = "https://api.weixin.qq.com/card/qrcode/create?access_token=".$asstonek
  42. $re2 = $this->curlp($url2,$fcardjson); 
  43. $re2arr = json_decode($re2,true); 
  44. $ewmticket = $re2arr['ticket']; 
  45. if($re2arr['errmsg']!='ok'exit($re2arr['errmsg']); 
  46. dump($re2arr); 
  47. echo '<img src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='.$ewmticket.'">'

卡卷投放(领取):html5 js api

  1. public function get_h5_card($data=array()){ 
  2.     $appid=$this->appid; 
  3.     $appsecret=$this->appsecret; 
  4.     $asstonek = $this->get_token($appid,$appsecret);      
  5.     $ticket = $this->get_card_ticket($asstonek); 
  6.     $data['api_ticket']=$ticket
  7.     $data['timestamp']=time(); 
  8.     $data['signature'] = self::getSign($data);   
  9.     //echo $ticket; 
  10.     $data2['card_id']=$data['card_id']; 
  11.     unset($data['api_ticket']); 
  12.     unset($data['card_id']); 
  13.     $data2['card_ext']=json_encode($data); 
  14.     return $data2
  15.     dump($data); 
  16. }    
  17.  
  18. public function tcard1(){//html5 js api 卡卷投放 
  19.         $card = new \Org\Util\Card('wx37445*******3ae8','6854f901**********4f9a3'); 
  20.         $cardid = 'pYKCus4Tmp_sBh6eiqfG-hN_ySzc'
  21.         $data['card_id']=$cardid
  22.         $data['code']=''
  23.         $data['openid']=''
  24.         $data2 = $card->get_h5_card($data); 
  25.         $this->assign('carddata',json_encode($data2)); 
  26.         //dump(($data2)); 
  27.         $this->siteDisplay ( 'card' ); 

需要完整卡卷投放接口请淘宝联系我.



zend