| 12345678910111213141516171819202122232425 |
- <?php
- namespace App\Services;
- class SmsService
- {
- private static string $uri = "https://api.smsbao.com/sms";
- private static string $username = "even7788";
- private static string $password = "Lpy@19920122";
- private static string $content = "【二八科技】您的验证码是{code}。如非本人操作,请忽略本短信";
- public static function sendPhoneCode($phone)
- {
- $code = mt_rand(100000, 999999);
- $password = md5(static::$password);
- $content = str_replace("{code}", $code, static::$content);
- $url = static::$uri . "?u=" . static::$username . "&p=" . $password;
- $url .= "&c=" . urlencode($content);
- $url .= "&m=" . $phone;
- $res = file_get_contents($url);
- return $res;
- }
- }
|