|
@@ -8,9 +8,6 @@ use Exception;
|
|
|
class SmsService
|
|
class SmsService
|
|
|
{
|
|
{
|
|
|
private static string $uri = "https://api.smsbao.com/sms";
|
|
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}。如非本人操作,请忽略本短信";
|
|
|
|
|
private static array $errors = [
|
|
private static array $errors = [
|
|
|
'30' => '错误密码',
|
|
'30' => '错误密码',
|
|
|
'40' => '账号不存在',
|
|
'40' => '账号不存在',
|
|
@@ -27,11 +24,16 @@ class SmsService
|
|
|
*/
|
|
*/
|
|
|
public static function sendPhoneCode($phone): bool
|
|
public static function sendPhoneCode($phone): bool
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
|
|
+ $username = config('services.sms.username');
|
|
|
|
|
+ $password = config('services.sms.password');
|
|
|
|
|
+ $content = config("services.sms.content");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
$code = mt_rand(100000, 999999);
|
|
$code = mt_rand(100000, 999999);
|
|
|
- $password = md5(static::$password);
|
|
|
|
|
|
|
+ $content = str_replace("{code}", $code, $content);
|
|
|
|
|
|
|
|
- $content = str_replace("{code}", $code, static::$content);
|
|
|
|
|
- $url = static::$uri . "?u=" . static::$username . "&p=" . $password;
|
|
|
|
|
|
|
+ $url = static::$uri . "?u=" . $username . "&p=" . md5($password);
|
|
|
$url .= "&c=" . urlencode($content);
|
|
$url .= "&c=" . urlencode($content);
|
|
|
$url .= "&m=" . $phone;
|
|
$url .= "&m=" . $phone;
|
|
|
$code = file_get_contents($url);
|
|
$code = file_get_contents($url);
|