php版本微信卡卷測試代碼api

來源:互聯網
上載者:User


建立卡卷:
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 '<img src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='.$ewmticket.'">';
        
        
        
    }
卡卷投放(領取):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' );
需要完整卡卷投放介面請淘寶聯絡我。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.