SmsBusiness.php 915 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\business;
  3. use Illuminate\Support\Arr;
  4. use support\Db;
  5. use support\Redis;
  6. use yzh52521\EasyHttp\Http;
  7. class SmsBusiness
  8. {
  9. /** 获取验证码
  10. * @param $phone
  11. * @param $code
  12. * @return void
  13. */
  14. static public function sms($phone, $code)
  15. {
  16. try {
  17. $data=Http::post('https://api.huanxun58.com/sms/Api/ReturnJson/Send.do',[
  18. 'SpCode'=>100428,
  19. 'LoginName'=>'maerdaifu',
  20. 'Password'=>'YKx!x4n4cg',
  21. 'MessageContent'=>'您的验证码是'.$code.',有效期5分钟',
  22. 'UserNumber'=>$phone,
  23. ])->array();
  24. if(Arr::get($data,'result') != 0){
  25. throw new \Exception(Arr::get($data,'description'));
  26. }
  27. }catch (\Exception $exception){
  28. throw new \Exception($exception->getMessage());
  29. }
  30. return true;
  31. }
  32. }