Ken преди 3 дни
родител
ревизия
1e291e918f
променени са 1 файла, в които са добавени 5 реда и са изтрити 13 реда
  1. 5 13
      app/Services/SmsService.php

+ 5 - 13
app/Services/SmsService.php

@@ -28,22 +28,14 @@ class SmsService
         $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;
         $res = file_get_contents($url);
-        $data['res'] = $res;
-        return $data;
-//        if (!empty(static::$errors[$res])) {
-//            throw new Exception(static::$errors[$res], HttpStatus::CUSTOM_ERROR);
-//        }
-//        if ($res != 0) throw new Exception("发送失败", HttpStatus::CUSTOM_ERROR);
-//        return $data;
+        if (!empty(static::$errors[$res])) {
+            throw new Exception(static::$errors[$res], HttpStatus::CUSTOM_ERROR);
+        }
+        if ($res != 0) throw new Exception("发送失败", HttpStatus::CUSTOM_ERROR);
+        return $code;
     }
 }