SmsApi.php 927 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace backend\models;
  3. class SmsApi extends BaseApi
  4. {
  5. public $apiUrl = 'sms';
  6. /**
  7. * @param string $mobile
  8. * @return array
  9. */
  10. public function sendCode($mobile)
  11. {
  12. $result = $this->get($this->apiUrl . '/send-code', ['mobile' => $mobile]);
  13. if ($result['code'] == 1) {
  14. return $this->returnArray(1, $result['data'], '验证码发送成功');
  15. } else {
  16. return $this->returnArray(0, [], '验证码发送失败');
  17. }
  18. }
  19. /**
  20. * @param string $mobile
  21. * @return array
  22. */
  23. public function getCode($mobile)
  24. {
  25. $result = $this->get($this->apiUrl . '/get-code', ['mobile' => $mobile]);
  26. if ($result['code'] == 1) {
  27. return $this->returnArray(1, $result['data'], '获取验证码成功');
  28. } else {
  29. return $this->returnArray(0, [], '获取验证码失败');
  30. }
  31. }
  32. }