Ken hace 3 días
padre
commit
66dc187240
Se han modificado 2 ficheros con 5 adiciones y 6 borrados
  1. 1 1
      app/Http/Controllers/api/ActivityReward.php
  2. 4 5
      app/Services/SmsService.php

+ 1 - 1
app/Http/Controllers/api/ActivityReward.php

@@ -34,7 +34,7 @@ class ActivityReward extends BaseController
 //            $key = 'api_request_' . md5(json_encode($keys));
 //            if (Cache::has($key)) throw new Exception("请求太频繁,请稍后再试。", HttpStatus::CUSTOM_ERROR);
 //            Cache::put($key, true, 60);
-            $code = SmsService::sendPhoneCode($params['phone']);
+          SmsService::sendPhoneCode($params['phone']);
         } catch (ValidationException $e) {
 
             return $this->error($e->validator->errors()->first());

+ 4 - 5
app/Services/SmsService.php

@@ -36,10 +36,9 @@ class SmsService
         $url .= "&c=" . urlencode($content);
         $url .= "&m=" . $phone;
         $code = file_get_contents($url);
-        return $code;
-//        if (!empty(static::$errors[$code])) {
-//            throw new Exception(static::$errors[$code], HttpStatus::CUSTOM_ERROR);
-//        }
-//        if ($code != 0) throw new Exception("发送失败:$code", HttpStatus::CUSTOM_ERROR);
+        if (!empty(static::$errors[$code])) {
+            throw new Exception(static::$errors[$code], HttpStatus::CUSTOM_ERROR);
+        }
+        if ($code != 0) throw new Exception("发送失败:$code", HttpStatus::CUSTOM_ERROR);
     }
 }