|
|
@@ -8,8 +8,16 @@ class SmsService
|
|
|
private static string $username = "even7788";
|
|
|
private static string $password = "Lpy@19920122";
|
|
|
private static string $content = "【二八科技】您的验证码是{code}。如非本人操作,请忽略本短信";
|
|
|
+ private static array $errors = [
|
|
|
+ '30' => '错误密码',
|
|
|
+ '40' => '账号不存在',
|
|
|
+ '41' => '余额不足',
|
|
|
+ '43' => "IP地址限制",
|
|
|
+ '50' => "内容含有敏感词",
|
|
|
+ '51' => '手机号码不正确'
|
|
|
+ ];
|
|
|
|
|
|
- public static function sendPhoneCode($phone)
|
|
|
+ public static function sendPhoneCode($phone): string
|
|
|
{
|
|
|
$code = mt_rand(100000, 999999);
|
|
|
$password = md5(static::$password);
|
|
|
@@ -18,8 +26,10 @@ class SmsService
|
|
|
$url = static::$uri . "?u=" . static::$username . "&p=" . $password;
|
|
|
$url .= "&c=" . urlencode($content);
|
|
|
$url .= "&m=" . $phone;
|
|
|
- $res = file_get_contents($url);
|
|
|
- return $res;
|
|
|
-
|
|
|
+ $code = file_get_contents($url);
|
|
|
+ if (!empty(static::$errors[$code]))
|
|
|
+ return static::$errors[$code];
|
|
|
+ if ($code == 0) return '已发送';
|
|
|
+ return "发送失败";
|
|
|
}
|
|
|
}
|