|
|
@@ -19,16 +19,21 @@ class SmsService
|
|
|
|
|
|
/**
|
|
|
* @param $phone
|
|
|
- * @return int
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static function sendPhoneCode($phone): int
|
|
|
+ public static function sendPhoneCode($phone)
|
|
|
{
|
|
|
$username = config('services.sms.username');
|
|
|
$password = config('services.sms.password');
|
|
|
$content = config("services.sms.content");
|
|
|
$code = mt_rand(100000, 999999);
|
|
|
$content = str_replace("{code}", $code, $content);
|
|
|
+ $data = [
|
|
|
+ 'username' => $username,
|
|
|
+ 'password' => $password,
|
|
|
+ 'phone' => $phone,
|
|
|
+ 'content' => $content,
|
|
|
+ ];
|
|
|
$url = static::$uri . "?u=" . $username . "&p=" . md5($password);
|
|
|
$url .= "&c=" . urlencode($content);
|
|
|
$url .= "&m=" . $phone;
|
|
|
@@ -37,6 +42,6 @@ class SmsService
|
|
|
throw new Exception(static::$errors[$res], HttpStatus::CUSTOM_ERROR);
|
|
|
}
|
|
|
if ($res != 0) throw new Exception("发送失败", HttpStatus::CUSTOM_ERROR);
|
|
|
- return $code;
|
|
|
+ return $data;
|
|
|
}
|
|
|
}
|