HuyiSms.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2021/2/2
  6. * Time: 14:50
  7. */
  8. namespace app\common\modules\sms\factory;
  9. use app\common\modules\sms\Sms;
  10. class HuyiSms extends Sms
  11. {
  12. public function sendBalance($mobile, $state)
  13. {
  14. return;
  15. }
  16. public function sendGoods($mobile, $state)
  17. {
  18. return;
  19. }
  20. public function sendMemberRecharge($mobile, $state)
  21. {
  22. return;
  23. }
  24. public function _sendCode($mobile, $state,$key='')
  25. {
  26. $code = $this->getCode($mobile,$this->key);
  27. $content = "您的验证码是:" . $code . "。请不要把验证码泄露给其他人。如非本人操作,可不用理会!";
  28. if ($state == '86') {
  29. $account = trim($this->sms['account']);
  30. $pwd = trim($this->sms['password']);
  31. $url = 'http://106.ihuyi.cn/webservice/sms.php?method=Submit';
  32. $smsrs = file_get_contents($url . '&account=' . $account . '&password=' . $pwd . '&mobile=' . $mobile . '&content=' . rawurlencode($content));
  33. } else {
  34. $account = trim($this->sms['account2']);
  35. $pwd = trim($this->sms['password2']);
  36. $url = 'http://api.isms.ihuyi.com/webservice/isms.php?method=Submit';
  37. $mobile = $state . ' ' . $mobile;
  38. $data = array(
  39. 'account' => $account,
  40. 'password' => $pwd,
  41. 'mobile' => $mobile,
  42. 'content' => $content,
  43. );
  44. $query = http_build_query($data);
  45. $smsrs = file_get_contents($url . '&' . $query);
  46. }
  47. $res = xml_to_array($smsrs);
  48. if ($res['SubmitResult']['code'] != 2) {
  49. return $res['SubmitResult']['msg'];
  50. }
  51. return true;
  52. }
  53. }