您好,欢迎访问一九零五行业门户网

PHP 微信卡券

微信卡券创建,删除等
1. [代码][php]代码 <?php /** * created by ${company}. * user: msli * date: 14-7-21 * time: 上午11:40 * purpose: 模型类 * to change this template use file | settings | file templates. */ namespace home\model; use think\model; use think\cache; class testmodel extends model { /* /* * 获取 所有奖项信息 */ public function index($openid){ /* $adapter = d("julymoviecodes"); $where['openid'] = $openid; $info = $adapter->where($where)->find(); return $info; */ } public function requesturl($url,$method){ $ch = curl_init($url); if($method=='get'){ curl_setopt($ch, curlopt_customrequest, 'get'); }else{ curl_setopt($ch, curlopt_customrequest, 'post'); } curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_useragent, 'mozilla/5.0 (windows nt 5.1; rv:21.0) gecko/20100101 firefox/21.0'); curl_setopt($ch, curlopt_ssl_verifypeer, false); $info = curl_exec($ch); $datajson = json_decode($info, true); return $datajson; } /*请求url,返回 access_token*/ public function get_access_token(){ $appid = c("appid"); $appkey = c("secret"); $access_token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$appkey.""; $accesstokenresult = $this->requesturl($access_token,'post'); $accesstoken = $accesstokenresult['access_token']; return $accesstoken; } //////获取wtw 的 access_token public function get_wtw_token(){ /////微信公众平台 access_token $time =time()*1000; $appid = 15; $token ="b4384c050f27b99151501b1a95eb529c"; $tmparr = array($token, $time, $appid); sort($tmparr,sort_string); $tmpstr = implode($tmparr); $signature = sha1($tmpstr); $userinfourl ="http://weixin.augmarketing.com/wechatconnect/app/accesstoken"."?appid=".$appid."&timestamp=".$time."&signature=".$signature.""; $userinfo = $this->requesturl($userinfourl,"get"); ///dump($userinfo); return $userinfo['data']['accesstoken']; } /* * 获取wtw 的 创建开卡接口() * * string(68) "{"errcode":0,"errmsg":"ok","card_id":"pplofjlz0kude55pz-cjgimr-yni"}" * 创建开卡成功,但是无法在微信后台显示? * */ public function get_cardadd(){ //获取access_token $access_token = $this->get_wtw_token(); $data = '{ "card":{ "card_type":"groupon", "groupon":{ "base_info":{ "logo_url": "http://www.supadmin.cn/uploads/allimg/120216/1_120216214725_1.jpg", "brand_name":"海底捞", "code_type":0, "title":"132元双人火锅套餐", "sub_title":"双人火锅套餐", "color":"color010", "notice": "使用时向服务员出示此券", "service_phone":"020-88888888", "description":"不可与其他优惠同享\n如需团购券发票,请在消费时向商户提出\n店内均可使用,仅限堂食\n餐前不可打包,餐后未吃完,可打包\n本团购券不限人数,建议2人使用,超过建议人数须另收酱料费5元/位\n本单谢绝自带酒水饮料", "date_info":{ "type":1, "begin_timestamp":1407577600, "end_timestamp":1419910400 }, "sku":{ "quantity": 50000000 }, "use_limit":1, "get_limit":3, "use_custom_code":true, "bind_openid":false, "can_share":true, "url_name_type":1 }, "deal_detail":"以下锅底2选1(有菌王锅、麻辣锅、大骨锅、番茄锅、清补凉锅、酸菜鱼锅可选):鲜菇猪肉滑1份18元\n金针菇1份16元\n黑木耳1份9元\n娃娃菜1份8元\n欢乐畅饮2位 12元\n自助酱料2位10元", } } }'; $add_url ="https://api.weixin.qq.com/card/add?access_token=".$access_token.""; $info = $this->wtw_request($add_url,$data); dump($info); } /* * 获取wtw 的 创建 会员卡 开卡接口() *string(68) "{"errcode":0,"errmsg":"ok","card_id":"pplofjsx3qc46vybx4a-pbo0fywa"}" * 创建开卡成功,但是无法在微信后台显示? * */ public function get_memcardadd($openid){ //获取access_token $access_token = $this->get_wtw_token(); $memadd_url ="https://api.weixin.qq.com/card/add?access_token=".$access_token.""; $sub_title = $this->get_cardidbyopenid($openid); ////激活链接 $activate_url ="https://wx.blinq.cn/cptest/diamond/index.php/index/indextest?wechat_card_js=1"; $data = '{ "card":{ "card_type":"member_card", "member_card":{ "base_info":{ "logo_url": "http://www.blinq.cn/public/i/i.png", "brand_name":"缤刻", "code_type":0, "title":"缤刻缤缤卡会员", "sub_title":"卡号:'.$sub_title.'", "color":"color010", "notice": "使用时向服务员出示此券", "service_phone":"020-88888888", "description":"不可与其他优惠同享\n如需团购券发票,请在消费时向商户提出\n店内均可使用,仅限堂食\n餐前不可打包,餐后未吃完,可打包\n本团购券不限人数,建议2人使用,超过建议人数须另收酱料费5元/位\n本单谢绝自带酒水饮料", "date_info":{ "type":1, "begin_timestamp":1407577600, "end_timestamp":1419910400 }, "sku":{ "quantity": 50000000 }, "use_limit":1, "get_limit":3, "use_custom_code":false, "bind_openid":true, "openid":"'.$openid.'", "can_share":false }, "supply_bonus":false, "supply_balance":false, "bonus_cleared":"不可转用其他人", "init_bonus":0, "init_balance":0, "prerogative":"不可与其他优惠同享\n如需团购券发票,请在消费时向商户提出\n店内均可使用", "bind_old_card_url":"'.$activate_url.'" } } }'; $info = $this->wtw_request($memadd_url,$data); $card_id = json_decode($info,true); return $card_id["card_id"]; } /* * 生成会员卡的 二维码 * * {"errcode":40053,"errmsg":"invalid action info, please check document"} */ public function get_member_qrcode(){ //获取access_token $access_token = $this->get_wtw_token(); $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=".$access_token.""; $data = '{ "action_name":"qr_card", "action_info":{ "card": { "card_id":"pplofjgeq4g41xlsveqdd4__wjlo", "openid": "oplofjvld4ltkp-8wpvotqjpvtny", "expire_seconds": "1800" , "is_unique_code": false }, "use_custom_code":true, } }'; $qrcoderes= $this->wtw_request($url,$data); dump($qrcoderes); $qrcoderes=json_decode($qrcoderes,true); //$qrcodeurl = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='. urlencode($qrcoderes['ticket']); ///echo "<img src='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={$qrcoderes['ticket']}' />"; //return $qrcoderes; } /* * * 微信通过 调用api激活会员卡 */ public function active_member(){ $access_token = $this->get_wtw_token(); $active_url ="https://api.weixin.qq.com/card/membercard/activate?access_token=".$access_token.""; /* $data ='{ "init_bonus":100, "init_balance":100, "membership_number":"1823554", "code":"798912843155", "card_id":"pplofjhdhao6zufyuzmfhwilupgm" }'; $member_info = $this->wtw_request($active_url,$data); dump($member_info);*/ } /* * 会员卡编号及积分信息 */ public function get_memberinfo(){ } /* * 获取 的 创建 电影票 开卡接口() * 创建电影票成功 * string(68) "{"errcode":0,"errmsg":"ok","card_id":"pplofjttwd0lh97lqorflqpcfjui"}" */ public function get_movieticketadd(){ //获取access_token $access_token = $this->get_wtw_token(); $data = '{ "card":{ "card_type":"movie_ticket", "movie_ticket":{ "base_info":{ "logo_url": "http://www.blinq.cn/upload/images/activityimages/2014/7/24/14/2014072414192526572vh_615&460.jpg", "brand_name":"秦时明月", "code_type":0, "title":"秦时明月之龙腾万里", "sub_title":"秦时明月之龙腾万里", "color":"color010", "notice": "使用时向服务员出示此券", "service_phone":"020-88888888", "description":"不可与其他优惠同享", "date_info":{ "type":1, "begin_timestamp":1407577600, "end_timestamp":1419910400 }, "sku":{ "quantity": 50000000 }, "use_limit":1, "get_limit":3, "use_custom_code":true, "bind_openid":false, "can_share":true, "url_name_type":1 }, "deal_detail":"改编自拥有500万粉丝的中国第一人气武侠动画系列剧《秦时明月》,即将于2013年暑期上映", } } }'; $add_url ="https://api.weixin.qq.com/card/add?access_token=".$access_token.""; $info = $this->wtw_request($add_url,$data); dump($info); } /* * 拉取门店列表 * * "errcode":0,"errmsg":"ok","location_list":[{"id":526,"name":"烈士陵园","phone":"","address":"地铁1号线","longitude":113.285392761,"latitude":23.1267681122} */ public function get_storelist(){ //获取access_token $access_token = $this->get_wtw_token(); $url = "https://api.weixin.qq.com/card/location/batchget?access_token=".$access_token.""; $data ='{ "offset":0, "count":50 }'; $storelist = $this->wtw_request($url,$data); return $storelist; } /* * 获取颜色列表接口 * * {"errcode":0,"errmsg":"ok","colors":[{"name":"color010","value":"#55bd47"},{"name":"color020","value":"#10ad61"} */ public function get_colorslist(){ //获取access_token $access_token = $this->get_wtw_token(); $url = "https://api.weixin.qq.com/card/getcolors?access_token=".$access_token.""; $data = null; $colorslist = $this->wtw_request($url,$data); return $colorslist; } /* * 生成卡券二维码 * * {"errcode":40053,"errmsg":"invalid action info, please check document"} */ public function get_qrcode(){ //获取access_token $access_token = $this->get_wtw_token(); $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=".$access_token.""; $data = '{ "action_name":"qr_card", "action_info":{ "card": { "card_id":"pplofjhdhao6zufyuzmfhwilupgm", "is_unique_code":false, }, "use_custom_code":true, } }'; $qrcoderes= $this->wtw_request($url,$data); $qrcoderes=json_decode($qrcoderes,true); $qrcodeurl = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='. urlencode($qrcoderes['ticket']); echo "<img src='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={$qrcoderes['ticket']}' />"; //return $qrcoderes; } /* * 添加到 卡包 weixinjs * */ /* * 卡券核销部分 * 该卡已核销 * * "string(117) "{"errcode":0,"errmsg":"ok","card":{"card_id":"pplofjhdhao6zufyuzmfhwilupgm"},"openid":"oplofjvld4ltkp-8wpvotqjpvtny"}" */ public function get_carddestroy($code =0 ,$card_id=0){ //$code = 656268747314 ; //$card_id ="pplofjhdhao6zufyuzmfhwilupgm"; $access_token = $this->get_wtw_token(); $url = "https://api.weixin.qq.com/card/code/consume?access_token=".$access_token.""; $data = '{ "code":"'.$code.'", "card_id":'.$card_id.' }'; $card_del= $this->wtw_request($url,$data); return $card_del; } /* * 会员卡交易(卡券支持优惠券(代金券、折扣券、礼品券、团购券)、会员卡、景点门票、门票、电影票) * * "errcode":40071,"errmsg":"invalid card type"}//////因为暂时 没有 开通会员卡 */ public function get_membertrade(){ //获取access_token $access_token = $this->get_wtw_token(); $url = "https://api.weixin.qq.com/card/membercard/updateuser?access_token=".$access_token.""; $data = '{ "code":"798912843155", "card_id":"pplofjhdhao6zufyuzmfhwilupgm", "record_bonus":"消费30元,获得3积分", "add_bonus":3, "add_balance":-300, "record_balance":"购买焦糖玛琪朵一杯,扣除金额30元" }'; $membercard_update= $this->wtw_request($url,$data); dump($membercard_update); } /* * 领取电影票后通过调用更新电影票接口update电影信息及用户选座信息 *{"errcode":0,"errmsg":"ok"}" */ public function get_movietrade(){ //获取access_token $access_token = $this->get_wtw_token(); $url = "https://api.weixin.qq.com/card/movieticket/updateuser?access_token=".$access_token.""; $data = '{ "code":"277217129962", "card_id":"p1pj9jr90_sqravqyi239ka1erki", "ticket_class":"4d", "show_time":1408493192, "screening_room":"5号影厅", "seat_number":"5排14号" }'; $movie_update= $this->wtw_request($url,$data); dump($movie_update); } /* * 拉起卡券列表(choosecard)jsapi,weixinjs * */ /* * code解码接口 * "{"errcode":0,"errmsg":"ok","code":"992718526867"}"/////反向推导,这个code是正确的; */ public function get_codedecrypt(){ $access_token = $this->get_wtw_token(); $url = "https://api.weixin.qq.com/card/code/decrypt?access_token=".$access_token.""; $data ='{ "encrypt_code":"xxizttmqcxwoaawoe91+vjdsfmv7b8g0vzizkqf4gwa60fzpc8ksz/5zz0dvkxde" }'; $decrypt= $this->wtw_request($url,$data); dump($decrypt); } /* * code 加密 接口 * * "{"errcode":0,"errmsg":"ok","code":"992718526867"}"/////反向推导,这个code是正确的; */ public function get_codeencrypt(){ $access_token = $this->get_wtw_token(); //$decrypt= $this->wtw_request($url,$data); //dump($decrypt); } /* * 卡券管理---删除卡券 * * string(27) "{"errcode":0,"errmsg":"ok"}" */ public function get_carddelete(){ $access_token = $this->get_wtw_token(); $url = "https://api.weixin.qq.com/card/delete?access_token=".$access_token.""; $data ='{ "card_id":"pplofjttwd0lh97lqorflqpcfjui" }'; $delete= $this->wtw_request($url,$data); dump($delete); } /* * 查询code * * {"errcode":40056,"errmsg":"invalid serial code"}" */ public function get_codeget(){ //获取access_token $access_token = $this->get_wtw_token(); $url = "https://api.weixin.qq.com/card/code/get?access_token=".$access_token.""; $data ='{ "code":"798912843155" }'; $codeget= $this->wtw_request($url,$data); dump($codeget); $data = json_decode($codeget,true); $openid = $data["openid"]; $userinfo = $this->get_subscribe_res($openid); $result = $this->get_opencard_res("13761029787"); } /* * 批量查询卡列表 * *{"errcode":0,"errmsg":"ok","card_id_list":["pplofjikhdavmdmjn0wqvolghtbg","pplofjhdhao6zufyuzmfhwilupgm"],"total_num":2}" */ public function get_cardgetall(){ //获取access_token $access_token = $this->get_wtw_token(); //dump($access_token); $url = "https://api.weixin.qq.com/card/batchget?access_token=".$access_token.""; $data ='{ "offset": 0, "count":10 }'; $cardgetall= $this->wtw_request($url,$data); //dump($cardgetall); return $cardgetall; } /* * 查询卡券详情 * * {"errcode":0,"errmsg":"ok","card":{"card_type":"general_coupon","general_coupon":{"base_info":{"id":"pplofjhdhao6zufyuzmfhwilupgm","logo_url":"http:\/\/m */ public function get_carddetail(){ //获取access_token $access_token = $this->get_wtw_token(); $url = "https://api.weixin.qq.com/card/get?access_token=".$access_token.""; $data ='{ "card_id":"pplofjhdhao6zufyuzmfhwilupgm" }'; $carddetail= $this->wtw_request($url,$data); dump(json_decode($carddetail)); } /* * 事件推送 * * {"errcode":0," */ public function get_event(){ $access_token = $this->get_wtw_token(); ///$carddetail= $this->wtw_request($url,$data); $touser = "oplofjqw1fktduqpk1vdxcf7k8s0"; $fromuser ="oplofjqw1fktduqpk1vdxcf7k8s0"; $time = time(); $cardid ="pplofjhdhao6zufyuzmfhwilupgm"; $texttpl ="<xml> <tousername><![cdata[".$touser."]]></tousername> <fromusername><![cdata[.$fromuser.]]></fromusername> <createtime>".$time."</createtime> <msgtype><![cdata[event]]></msgtype> <event><![cdata[card_pass_check]]></event> <cardid><![cdata[".$cardid."]]></cardid> <isgivebyfriend>1</isgivebyfriend> <usercardcode><![cdata[12312312]]></usercardcode> </xml>"; } /* * 更改 code * * {"errcode":0,"code 无效 */ public function get_codeupdate(){ //获取access_token $access_token = $this->get_wtw_token(); dump($access_token); $update_url = "https://api.weixin.qq.com/card/code/update?access_token=".$access_token.""; $data ='{ "code":"151322901878", "card_id":"pplofjhdhao6zufyuzmfhwilupgm", "new_code":"151322901879", }'; /* $codeupdate = $this->wtw_request($update_url,$data); dump($codeupdate); */ } /* * 卡券失效接口 * * {"errcode":0,"code无效 */ public function get_codeunable(){ //获取access_token $access_token = $this->get_wtw_token(); $unable_url = "https://api.weixin.qq.com/card/code/unavailable?access_toke=".$access_token.""; $data ='{ "code":"151322901878", "card_id":"pplofjhdhao6zufyuzmfhwilupgm" }'; /* $codeunable= $this->wtw_request($unable_url,$data); dump($codeunable); */ } /* * 添加白名单(果子的 ) * * */ public function get_whitelist(){ //获取access_token $access_token = $this->get_wtw_token(); $white_url = "https://api.weixin.qq.com/card/testwhitelist/set?access_toke=".$access_token.""; $data ='{ "openid":[ "oplofjksqlgxspdil2wssywda_zu" ] }'; /* $whileresult= $this->wtw_request($white_url,$data); dump($whileresult); */ } /*请求url,判断用户是否已经关注*/ public function get_subscribe_res($openid){ /////微信公众平台 $time =time()*1000; $appid = 15; $token ="b4384c050f27b99151501b1a95eb529c"; $tmparr = array($token, $time, $appid); sort($tmparr,sort_string); $tmpstr = implode($tmparr); $signature = sha1($tmpstr); $userinfourl ="http://weixin.augmarketing.com/wechatconnect/app/users/property/".$openid."?appid=".$appid."&timestamp=".$time."&signature=".$signature.""; $userinfo = $this->requesturl($userinfourl,"get"); ///dump($userinfo); return $userinfo; } /* * * 得到签名signature 的查询字符串 */ public function getsortquerystring($params = array(), $exceptkeys = array()) { $querysting = ''; ksort($params); foreach ($params as $key => $value) { if(!in_array($key, $exceptkeys)) { $querysting .= self::urlencode($key) . '=' . self::urlencode($value) . '&'; } } return mb_substr($querysting, 0, mb_strlen($querysting) - 1); } /* * urlencode加密字符串 */ public static function urlencode($string = '') { return str_replace('~', '%7e', rawurlencode($string)); } /* * urldecode解密字符串 */ public static function urldecode($string = '' ) { return str_replace('%20', '+', str_replace('%2a', '*', rawurldecode($string))); } public function signature($params = array(), $token) { $querystring = $this->getsortquerystring($params, array('sig')); return urlencode(base64_encode(hash_hmac('sha256', $querystring, $token, true))); } /* * 调用开卡接口 */ public function get_opencard_res($telephone){ $ts = strtotime('now'); ///$telephone ="18621383387"; $appkey ='3ccdb900'; $secret ="957a8ca7a73c4d14d070fbb819eb864a"; ////sig签名生成需要secret,appkey 3ccdb900对应的secret是:957a8ca7a73c4d14d070fbb819eb864a;$signature = urlencode(base64_encode(hash_hmac("sha256","app_key=urlencoded(".$appkey.")&check=urlencoded(1)&ts=urlencoded(".$time.")",$secret,true))); $params = array( 'app_key' => $appkey, 'ts' => $ts, 'uuid' => $telephone, ); $sig = $this->signature($params,$secret); $opencardurl ="http://mmapi.blinq.augmarketing.com/benefit/list?app_key=3ccdb900&ts=".$ts."&uuid=".$telephone."&sig=".$sig.""; $opencardinfo = $this->requesturl($opencardurl, "get"); //dump($opencardinfo); if(!empty($opencardinfo)){ if(!empty($opencardinfo["data"])){ return 1; }else{ return 0; } }else{ return 0; } } /*请求url,通过 当前微信号openid 获取用户member_id */ public function get_member_id($openid){ $ts = strtotime('now'); ///$telephone ="18621383387"; $appkey ='3ccdb900'; $secret ="957a8ca7a73c4d14d070fbb819eb864a"; ////sig签名生成需要secret,appkey 3ccdb900对应的secret是:957a8ca7a73c4d14d070fbb819eb864a;$signature = urlencode(base64_encode(hash_hmac("sha256","app_key=urlencoded(".$appkey.")&check=urlencoded(1)&ts=urlencoded(".$time.")",$secret,true))); $params = array( 'app_key' => $appkey, 'ts' => $ts, 'attribute_id' => 9, 'attribute_value'=>$openid ); $sig = $this->signature($params,$secret); $member_url ="http://mmapi.blinq.augmarketing.com/member/list?app_key=3ccdb900&ts=".$ts."&sig=".$sig."&attribute_id=9&attribute_value=$openid"; $member_info = $this->requesturl($member_url, "get"); dump($member_info); return $member_info["data"]["items"][0]["member_id"]; } /*请求url,通过 当前微信号openid 获取用户 微生活卡号 member_id */ public function get_member_cardid($member_id=669937){ $ts = strtotime('now'); ///$telephone ="18621383387"; $appkey ='3ccdb900'; $secret ="957a8ca7a73c4d14d070fbb819eb864a"; ////sig签名生成需要secret,appkey 3ccdb900对应的secret是:957a8ca7a73c4d14d070fbb819eb864a;$signature = urlencode(base64_encode(hash_hmac("sha256","app_key=urlencoded(".$appkey.")&check=urlencoded(1)&ts=urlencoded(".$time.")",$secret,true))); $params = array( 'app_key' => $appkey, 'ts' => $ts, 'member_id' => $member_id ); $sig = $this->signature($params,$secret); $member_url ="http://mmapi.blinq.augmarketing.com/member/detail?app_key=3ccdb900&ts=".$ts."&sig=".$sig."&member_id=$member_id"; $member_info = $this->requesturl($member_url, "get"); dump($member_info); //return $member_info["data"]["card_number"]; ///dump($member_info); } ////获取用户 微生活卡号 public function get_cardidbyopenid($openid){ $cardid = $this->get_member_id($openid); return $this->get_member_cardid($cardid); } // 允许 public function allowbenefit($telephone){ $cache = cache::getinstance('redis'); $key = "diamond_benefit:get_benefit_value_".$telephone ; $times = $cache->get($key); if (empty($times) || ($times==false)){ $value = $this->get_opencard_res($telephone); $cache->set($key,$value); return $value; } return $times; } /* * curl 请求 */ public function wtw_request($url,$data=null){ $curl = curl_init(); // 启动一个curl会话 curl_setopt($curl, curlopt_url, $url); // 要访问的地址 curl_setopt($curl, curlopt_ssl_verifypeer, false); // 对认证证书来源的检查 curl_setopt($curl, curlopt_ssl_verifyhost, false); // 从证书中检查ssl加密算法是否存在 curl_setopt($curl, curlopt_useragent, $_server['http_user_agent']); // 模拟用户使用的浏览器 if($data != null){ curl_setopt($curl, curlopt_post, 1); // 发送一个常规的post请求 curl_setopt($curl, curlopt_postfields, $data); // post提交的数据包 } curl_setopt($curl, curlopt_timeout, 300); // 设置超时限制防止死循环 curl_setopt($curl, curlopt_header, 0); // 显示返回的header区域内容 curl_setopt($curl, curlopt_returntransfer, 1); // 获取的信息以文件流的形式返回 $info = curl_exec($curl); // 执行操作 if (curl_errno($curl)) { echo 'errno:'.curl_getinfo($curl);//捕抓异常 dump(curl_getinfo($curl)); } return $info; } /* * 模板消息 */ public function templetemsg(){ //获取access_token /*string(86) "8jvpkfjaiemsnqf-ht2laqklcjqnd6amyku1zpujiea1tl45lgsxocybkymjcgbg0fdybef6s4a7q41kphznag" * string(45) "{"errcode":0,"errmsg":"ok","msgid":201652404}" */ $access_token = $this->get_wtw_token(); dump($access_token); $msg_url="https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$access_token.""; $time = date("y-m-d h:i:s",time()); $url ="http://www.blinq.cn/"; ////这个链接是点击图文 跳转的链接,换行只能用\n 不能用<br/> ////请求包为一个json: $msg_json= '{ "touser":"oplofjqw1fktduqpk1vdxcf7k8s0", "template_id":"izohjfsa-ax2uudlzjjx6irwursvddhd4tqpnm8kfsy", "url":"'.$url.'", "topcolor":"#ff0000", "data":{ "first":{ "value":"尊敬的李先生:\n恭喜你模板接口调用成功了\n\n", "color":"#000000" }, "keyword1":{ "value":"模板接口调用测试\n\n", "color":"#000000" }, "keyword2":{ "value":"'.$time.'\n\n", "color":"#000000" }, "remark":{ "value":"\n\nthis message is intended only for the use of the inpidual or entity激活成功", "color":"#0099ff" } } }' ; $result = $this->wtw_request($msg_url,$msg_json); ///$result = $this->msg_request($msg_url, $msg_json, $header = array()); dump($result); } }
其它类似信息

推荐信息