Aliyunsms.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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'])
  54. ->tempCode($params['temp'])
  55. ->code($params['code'])
  56. ->bind($params['params'])
  57. ->send();
  58. }
  59. /**
  60. * 短信发送通知(msg参数直接构建实际短信内容即可)
  61. * @param array $params
  62. * @return boolean
  63. * @throws \AlibabaCloud\Client\Exception\ClientException
  64. * @throws \AlibabaCloud\Client\Exception\ServerException
  65. */
  66. public function smsNotice(&$params)
  67. {
  68. $smsbao = new library\Aliyunsms();
  69. $result = $smsbao->mobile($params['mobile'])->msg($params['msg'])->send();
  70. return $result;
  71. }
  72. /**
  73. * 检测验证是否正确
  74. * @param Sms $params
  75. * @return boolean
  76. */
  77. public function smsCheck(&$params)
  78. {
  79. return TRUE;
  80. }
  81. }