首页 > 日志 > php 微信公众号发送模板消息

php 微信公众号发送模板消息

function sent_tjcg($id,$userid,$title,$bslb) {
//发送提交成功给提交者
$ACCESS_TOKEN=accessToken();
$f_url="http://xxxxxxxxxxx.php?id=".$id;
$remark="申请事项:".$title."\n点击随时查看办事进度。";
$data=array( 
    'touser'=>get_openid($userid), 
    'template_id'=>"Cbivn3X44mwS4q_14Lg_Mb4M0E1tU56w7LyhoVueluk",
    'url'=>$f_url,
    'data'=>array(
        'first'=>array('value'=>"您的办事申请已提交成功!",'color'=>"#009900"),
        'event'=>array('value'=>$bslb,'color'=>"#000000"),
        'dept'=>array('value'=>"xxxxxxx",'color'=>"#000000"), 
        'date'=>array('value'=>date("Y-m-d H:i:s",time()),'color'=>"#000000"), 
        'remark'=>array('value'=>$remark,'color'=>"#000000"),
    )
);
$json_data=json_encode($data);//转化成json数组让微信可以接收
$url="https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$ACCESS_TOKEN;//模板消息请求URL
$res=https_request($url,urldecode($json_data));//请求开始
return json_decode($res,true);

}

上一篇: php获取微信公众号access_token并存储到数据库

下一篇: PHP获取当前时间以及date相关格式

联盟广告