SmsService.php 775 B

12345678910111213141516171819202122232425
  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. $password = md5(static::$password);
  13. $content = str_replace("{code}", $code, static::$content);
  14. $url = static::$uri . "?u=" . static::$username . "&p=" . $password;
  15. $url .= "&c=" . urlencode($content);
  16. $url .= "&m=" . $phone;
  17. $res = file_get_contents($url);
  18. return $res;
  19. }
  20. }