Sms.php 935 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare (strict_types = 1);
  3. namespace library\utils;
  4. use library\utils\Sms\TencentSms;
  5. class Sms {
  6. /**
  7. * 发送模板短信【前台使用】
  8. * @param $tel
  9. * @param $code
  10. * @param array $array
  11. * @return mixed
  12. */
  13. public function SmsCode($tel, $code, $array = array()) {
  14. $data = $this->SmsSendTpl($tel, $code, $array);
  15. if ($data['Code'] == 'OK') {
  16. $r['status'] = 1;
  17. $r['error'] = 'ok';
  18. } else {
  19. $r['status'] = -1;
  20. $r['error'] = $data['Message'];
  21. }
  22. return $r;
  23. }
  24. /**
  25. * 发送模板的数据
  26. * @param $tel 手机号码
  27. * @param $code code
  28. * @param array $array
  29. * @return mixed|null
  30. */
  31. function SmsSendTpl($tel, $code, $array = array()) {
  32. $tencent = new TencentSms();
  33. $r = $tencent->SmsSendTmplete($tel,$code,$array);
  34. return $r;
  35. }
  36. }