Ken 3 dni temu
rodzic
commit
db7c0d8a60
1 zmienionych plików z 8 dodań i 3 usunięć
  1. 8 3
      app/Services/SmsService.php

+ 8 - 3
app/Services/SmsService.php

@@ -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;
     }
 }