修复公众号提示因为超出字符限制而无法通知的问题
This commit is contained in:
parent
865020e063
commit
b984b12824
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user