SmsService.php 738 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace App\Services;
  3. class SmsService
  4. {
  5. private static string $uri = "https://api.smsbao.com/sms";
  6. private static string $username = "even7788";
  7. private static string $password = "Lpy@19920122";
  8. private static string $content = "【二八科技】您的验证码是{code}。如非本人操作,请忽略本短信";
  9. public static function sendPhoneCode($phone)
  10. {
  11. $code = mt_rand(100000, 999999);
  12. $content = str_replace("{code}", $code, static::$content);
  13. $url = static::$uri . "?u=" . static::$username . "&p=" . static::$password;
  14. $url .= "&c=" . urlencode($content);
  15. $url .= "&m=" . $phone;
  16. $res = file_get_contents($url);
  17. return $res;
  18. }
  19. }