45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
use EasyWeChat\Foundation\Application as OfficialAccount;
|
|
/**
|
|
* 微信消息通知
|
|
* @extends CI_Model
|
|
*/
|
|
class Weixin_message_model extends CI_Model {
|
|
|
|
//绑定成功通知:样本编号,检测项目
|
|
const TEMPLATE_ACTIVE = '1mTetEn_7WR2dJX7-QO6vzVpNcVW_vjzzJmRzNcq_ZM';
|
|
//样品发货提醒:样品名称,样品快递号,时间
|
|
const TEMPLATE_SENT = '7Nt6MCScb1AbDqejv9ACKvTc2hmLZAm65qsS9CHRLF8';
|
|
//检测报告通知:检测码,报告生成时间
|
|
const TEMPLATE_RESULT = 'CtR0vfHcNjaYSK6IE-xlKbBQDGTkeSYFJu9_bYE5si8';
|
|
|
|
/**
|
|
* 发送通知
|
|
* @param $toUser
|
|
* @param $template_id
|
|
* @param $url
|
|
* @param $msg first,keyword1,keyword2,keyword3,remark
|
|
* @return bool
|
|
**/
|
|
public function send($toUser,$template_id,$url,$msg)
|
|
{
|
|
$conf = $this->config->item('weixin_uah');
|
|
$config = [
|
|
'app_id' => $conf['AppId'],
|
|
'secret' => $conf['AppSecert'],
|
|
'token' => $conf['Token'],
|
|
'aes_key' => $conf['EncodingAESKey'],
|
|
'response_type' => 'array',
|
|
];
|
|
$app = new OfficialAccount($config);
|
|
$app->notice->send([
|
|
'touser' => $toUser,
|
|
'template_id' => $template_id,
|
|
'url' => $url,
|
|
'data' => $msg
|
|
]);
|
|
}
|
|
|
|
}
|