GSMMessage.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. //这个文件用来实现与短信相关的函数
  3. function SendGSMMessage($phone, $content)
  4. {
  5. $name = "SDK-ZQ-XXKJ-0482";
  6. $pwd = "hhyz122131";
  7. $msg = rawurlencode($content);
  8. $res = file_get_contents("http://sms.4006555441.com/webservice.asmx/mt?Sn=" . $name . "&Pwd=" . $pwd . "&mobile=" . $phone . "&content=" . $msg);
  9. return $res;
  10. }
  11. function GetRandomNum()
  12. {
  13. $str = '0123456789';
  14. $rndcode = rand(0,9);
  15. $rndNum = $str[$rndcode];
  16. return $rndNum;
  17. }
  18. function SendCaptcha($phone, $shopname)
  19. {
  20. //先生成一个随机的6位数验证码
  21. $Char1 = $this->GetRandomNum();
  22. $Char2 = $this->GetRandomNum();
  23. $Char3 = $this->GetRandomNum();
  24. $Char4 = $this->GetRandomNum();
  25. $Char5 = $this->GetRandomNum();
  26. $Char6 = $this->GetRandomNum();
  27. $captcha = $Char1 . $Char2 . $Char3 . $Char4 . $Char5 . $Char6;
  28. $content = "尊敬的顾客您好,您本次在店铺“" . $shopname . "”微信点单的验证码为" . $captcha . ",请您在订单提交页面输入本验证码进行手机号码验证,验证码有效时间10分钟。";
  29. SendGSMMessage($phone, $content);
  30. }
  31. ?>