Home  >  Article  >  php教程  >  php版本微信卡卷测试代码api

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

WBOY
WBOYOriginal
2016-06-08 17:20:141401browse

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

<script>ec(2);</script>


创建卡卷:
public function createcard(){//新建卡卷
    $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":"海底捞123",
"code_type":" CODE_TYPE_TEXT ",
"title": "132 元双人火锅套餐",
"sub_title": "",
"color": "Color010",
"notice": "使用时向服务员出示此券",
"service_phone": "020-88888888",
"description": "不可与其他优惠同享\n 如需团购券发票, 请在消费时向商户提出\n 店内均可
使用,仅限堂食\n 餐前不可打包,餐后未吃完,可打包\n 本团购券不限人数,建议 2 人使用,超过建议人
数须另收酱料费 5 元/位\n 本单谢绝自带酒水饮料",
"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": "立即使用",
"custom_url": "http://www.qq.com",
"custom_url_sub_title": "6 个汉字 tips",
"promotion_url_name": "更多优惠",
"promotion_url": "http://www.qq.com",
"source": "大众点评"
},
"deal_detail": "以下锅底 2 选 1(有菌王锅、麻辣锅、大骨锅、番茄锅、清补凉锅、酸菜鱼锅可
选):\n 大锅 1 份 12 元\n 小锅 2 份 16 元\n 以下菜品 2 选 1\n 特级肥牛 1 份 30 元\n 洞庭?鱼卷 1 份
20 元\n 其他\n 鲜菇猪肉滑 1 份 18 元\n 金针菇 1 份 16 元\n 黑木耳 1 份 9 元\n 娃娃菜 1 份 8 元\n 冬
瓜 1 份 6 元\n 火锅面 2 个 6 元\n 欢乐畅饮 2 位 12 元\n 自助酱料 2 位 10 元"}
}
}';
 
 
$re3 = $this->curlp($url,$pjson);
        $re3arr = json_decode($re3,true);
        dump($re3arr);
    
    }
卡卷领取测试:(二维码)
public function tcard(){//卡卷测试
    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);
        
        
        /*  获取卡卷列表
        $url = "https://api.weixin.qq.com/card/batchget?access_token=".$asstonek;
        $jsondata = '{"offset":0,"count":10}';
        $re = $this->curlp($url,$jsondata);
        dump($re);
        */
        
        //  获取卡卷详情
        $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  卡卷审核通过
        //  获取卡卷详情
        
        
        $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 'php版本微信卡卷测试代码api';
        
        
        
    }
卡卷投放(领取):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 = 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' );
需要完整卡卷投放接口请淘宝联系我。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn