From b984b128248fc17fb1a526543336cbdbee6bb5fe Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Sat, 3 Aug 2024 10:56:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=AC=E4=BC=97=E5=8F=B7?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=9B=A0=E4=B8=BA=E8=B6=85=E5=87=BA=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E9=99=90=E5=88=B6=E8=80=8C=E6=97=A0=E6=B3=95=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/weixin/Getgzopenid.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/extend/weixin/Getgzopenid.php b/extend/weixin/Getgzopenid.php index 11a0213b..6b2274fd 100755 --- a/extend/weixin/Getgzopenid.php +++ b/extend/weixin/Getgzopenid.php @@ -78,19 +78,28 @@ class Getgzopenid } return $token_data[1]; } + public function sendWeixingongzhonghao($access_token,$address,$user_msg,$goods_msg){ $token_url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$access_token; + + $max_length = 20; + $replacement = '...'; + foreach($goods_msg as $key=>$value){ foreach($value['goodscontact'] as $k=>$v){ // TODO 暂时将openid写死,因为后端在这一块设计的不好,这里的open_id是张姐的 + $str = $value['goods_name'].",数量:".$value['goods_num']; + if (mb_strlen($str) > $max_length) { + $str = mb_substr($str, 0, $max_length - mb_strlen($replacement)) . $replacement; + } $data=[ "touser" => $v['open_id'] ? $v['open_id'] : 'oUzra6HlpaARciJpUk8eeUxFayPk' , "template_id"=>"oWpOaEVOgiORQ4bDj9d5u98YMhWWyuShrxECO5RKBW8", "data"=>[ "thing2"=>["value"=>$user_msg['contact']], "phone_number3"=>["value"=>$user_msg['telephone']], - "thing4"=>["value"=>$value['goods_name'].",数量:".$value['goods_num']], - "thing5"=>["value"=>$address], + "thing4"=>["value" => $str], + "thing5"=>["value" => $address], "time6"=>["value"=>date("Y-m-d H:i:s")], ] ]; @@ -99,6 +108,7 @@ class Getgzopenid } } } + public function http($url, $method = '', $postfields = null, $headers = array(), $debug = false) { $ci = curl_init();