Aliyunsms.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace addons\aliyunsms;
  3. use app\common\library\Menu;
  4. use app\common\model\Sms;
  5. use think\Addons;
  6. /**
  7. * Aliyunsms插件
  8. */
  9. class Aliyunsms extends Addons
  10. {
  11. /**
  12. * 插件安装方法
  13. * @return bool
  14. */
  15. public function install()
  16. {
  17. return true;
  18. }
  19. /**
  20. * 插件卸载方法
  21. * @return bool
  22. */
  23. public function uninstall()
  24. {
  25. return true;
  26. }
  27. /**
  28. * 插件启用方法
  29. * @return bool
  30. */
  31. public function enable()
  32. {
  33. return true;
  34. }
  35. /**
  36. * 插件禁用方法
  37. * @return bool
  38. */
  39. public function disable()
  40. {
  41. return true;
  42. }
  43. /**
  44. * 短信发送
  45. * @param Sms $params
  46. * @return mixed
  47. * @throws \AlibabaCloud\Client\Exception\ClientException
  48. * @throws \AlibabaCloud\Client\Exception\ServerException
  49. */
  50. public function smsSend(&$params)
  51. {
  52. $smsbao = new library\Aliyunsms();
  53. return $smsbao->mobile($params['mobile'])->msg($params['code'])->event($params['event'])->params($params['params'])->send();
  54. }
  55. /**
  56. * 短信发送通知(msg参数直接构建实际短信内容即可)
  57. * @param array $params
  58. * @return boolean
  59. * @throws \AlibabaCloud\Client\Exception\ClientException
  60. * @throws \AlibabaCloud\Client\Exception\ServerException
  61. */
  62. public function smsNotice(&$params)
  63. {
  64. $smsbao = new library\Aliyunsms();
  65. $result = $smsbao->mobile($params['mobile'])->msg($params['msg'])->send();
  66. return $result;
  67. }
  68. /**
  69. * 检测验证是否正确
  70. * @param Sms $params
  71. * @return boolean
  72. */
  73. public function smsCheck(&$params)
  74. {
  75. return TRUE;
  76. }
  77. }