protected function remind($student, $title, $html, $url, $mode = '1110') { $content = trim(strip_tags($this->br2nl($html))); $this->record("即将提醒【{$student['name']}】:" . strip_tags($html)); $types = array(); //socket提醒 if ('1' === $mode[0]) { $types[] = '推送'; Notice::socket($student['sid'], $title, $content, $url); } //企业号提醒 $articles = array('articles' => array(array('title' => $title, 'description' => $content))); if ('1' === $mode[1] && Notice::wechat($student['sid'], 'news', $articles)) { $types[] = '微信'; } //邮件提醒 if ('1' === $mode[2] && Notice::mail($student['mail'], $title, $html)) { $types[] = '邮件'; } //短信提醒 $smsParam = $student['sms']; $template = $smsParam['template']; if ('1' === $mode[3] && count($types) < 3 && Notice::sms($student['phone'], $template, $smsParam)) { $types[] = '短信'; } //记录提醒方式 $this->record("已通过如右所示方式提醒【{$student['name']}】:" . implode('、', $types)); }
public function sms() { $gid = \Hnust\input('group/d'); $template = \Hnust\input('template'); //获取群组成员 $group = new Group(); $member = $group->phone($gid); //发送短信 $success = 0; $error = array(); foreach ($member as $item) { if (Notice::sms($item['phone'], $template, $item)) { $success++; } else { $error[] = $item['name']; } } $this->msg = '通知发送结果'; $this->data = "成功发送{$success}条短信"; if (count($error)) { $this->data .= ',其中失败有:' . implode($error); } }