@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'key'=>env('ANTICAPTCHA_API_KEY','') |
|
4 | + 'key'=>env('ANTICAPTCHA_API_KEY','') |
|
5 | 5 | ]; |
6 | 6 | \ No newline at end of file |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | public $taskInfo; |
16 | 16 | |
17 | 17 | /** |
18 | - * Submit new task and receive tracking ID |
|
19 | - * @return bool |
|
20 | - * @throws AnticaptchaException |
|
21 | - */ |
|
18 | + * Submit new task and receive tracking ID |
|
19 | + * @return bool |
|
20 | + * @throws AnticaptchaException |
|
21 | + */ |
|
22 | 22 | public function createTask() { |
23 | 23 | |
24 | 24 | $postData = array( |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $submitResult = $this->jsonPostRequest("createTask", $postData); |
29 | 29 | |
30 | 30 | if ($submitResult == false) { |
31 | - throw new AnticaptchaException('API error'); |
|
31 | + throw new AnticaptchaException('API error'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | if ($submitResult->errorId == 0) { |
@@ -36,19 +36,19 @@ discard block |
||
36 | 36 | $this->debout("created task with ID {$this->taskId}", "yellow"); |
37 | 37 | return true; |
38 | 38 | } else { |
39 | - $this->setErrorMessage($submitResult->errorDescription); |
|
40 | - throw new AnticaptchaException("API error {$submitResult->errorCode} : {$submitResult->errorDescription}"); |
|
39 | + $this->setErrorMessage($submitResult->errorDescription); |
|
40 | + throw new AnticaptchaException("API error {$submitResult->errorCode} : {$submitResult->errorDescription}"); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | } |
44 | 44 | |
45 | - /** |
|
46 | - * @param int $maxSeconds |
|
47 | - * @param int $currentSecond |
|
48 | - * |
|
49 | - * @return bool |
|
50 | - * @throws AnticaptchaException |
|
51 | - */ |
|
45 | + /** |
|
46 | + * @param int $maxSeconds |
|
47 | + * @param int $currentSecond |
|
48 | + * |
|
49 | + * @return bool |
|
50 | + * @throws AnticaptchaException |
|
51 | + */ |
|
52 | 52 | public function waitForResult($maxSeconds = 300, $currentSecond = 0) { |
53 | 53 | $postData = array( |
54 | 54 | "clientKey" => $this->clientKey, |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $postResult = $this->jsonPostRequest("getTaskResult", $postData); |
65 | 65 | |
66 | 66 | if ($postResult == false) { |
67 | - throw new AnticaptchaException('API error'); |
|
67 | + throw new AnticaptchaException('API error'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $this->taskInfo = $postResult; |
@@ -83,25 +83,25 @@ discard block |
||
83 | 83 | return true; |
84 | 84 | } |
85 | 85 | $this->setErrorMessage("unknown API status, update your software"); |
86 | - throw new AnticaptchaException("unknown API status, update your software"); |
|
86 | + throw new AnticaptchaException("unknown API status, update your software"); |
|
87 | 87 | |
88 | 88 | } else { |
89 | 89 | $this->setErrorMessage($this->taskInfo->errorDescription); |
90 | - throw new AnticaptchaException("API error {$this->taskInfo->errorCode} : {$this->taskInfo->errorDescription}"); |
|
90 | + throw new AnticaptchaException("API error {$this->taskInfo->errorCode} : {$this->taskInfo->errorDescription}"); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | - /** |
|
95 | - * @return bool |
|
96 | - * @throws AnticaptchaException |
|
97 | - */ |
|
94 | + /** |
|
95 | + * @return bool |
|
96 | + * @throws AnticaptchaException |
|
97 | + */ |
|
98 | 98 | public function getBalance() { |
99 | 99 | $postData = array( |
100 | 100 | "clientKey" => $this->clientKey |
101 | 101 | ); |
102 | 102 | $result = $this->jsonPostRequest("getBalance", $postData); |
103 | 103 | if ($result == false) { |
104 | - throw new AnticaptchaException('API error'); |
|
104 | + throw new AnticaptchaException('API error'); |
|
105 | 105 | } |
106 | 106 | if ($result->errorId == 0) { |
107 | 107 | return $result->balance; |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | - /** |
|
114 | - * @param $methodName |
|
115 | - * @param $postData |
|
116 | - * |
|
117 | - * @return mixed |
|
118 | - * @throws AnticaptchaException |
|
119 | - */ |
|
113 | + /** |
|
114 | + * @param $methodName |
|
115 | + * @param $postData |
|
116 | + * |
|
117 | + * @return mixed |
|
118 | + * @throws AnticaptchaException |
|
119 | + */ |
|
120 | 120 | public function jsonPostRequest($methodName, $postData) { |
121 | 121 | |
122 | 122 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | if ($curlError != "") { |
147 | 147 | $this->debout("Network error: $curlError"); |
148 | - throw new AnticaptchaException("Network error: $curlError"); |
|
148 | + throw new AnticaptchaException("Network error: $curlError"); |
|
149 | 149 | } |
150 | 150 | curl_close($ch); |
151 | 151 | return json_decode($result); |
@@ -174,30 +174,30 @@ discard block |
||
174 | 174 | echo $CLIMsg."\n"; |
175 | 175 | } |
176 | 176 | |
177 | - /** |
|
178 | - * @param $message |
|
179 | - */ |
|
177 | + /** |
|
178 | + * @param $message |
|
179 | + */ |
|
180 | 180 | public function setErrorMessage($message) { |
181 | 181 | $this->errorMessage = $message; |
182 | 182 | } |
183 | 183 | |
184 | - /** |
|
185 | - * @return mixed |
|
186 | - */ |
|
184 | + /** |
|
185 | + * @return mixed |
|
186 | + */ |
|
187 | 187 | public function getErrorMessage() { |
188 | 188 | return $this->errorMessage; |
189 | 189 | } |
190 | 190 | |
191 | - /** |
|
192 | - * @return mixed |
|
193 | - */ |
|
191 | + /** |
|
192 | + * @return mixed |
|
193 | + */ |
|
194 | 194 | public function getTaskId() { |
195 | 195 | return $this->taskId; |
196 | 196 | } |
197 | 197 | |
198 | - /** |
|
199 | - * @param $taskId |
|
200 | - */ |
|
198 | + /** |
|
199 | + * @param $taskId |
|
200 | + */ |
|
201 | 201 | public function setTaskId($taskId) { |
202 | 202 | $this->taskId = $taskId; |
203 | 203 | } |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | interface AntiCaptchaTaskProtocol { |
6 | 6 | |
7 | - public function getPostData(); |
|
7 | + public function getPostData(); |
|
8 | 8 | |
9 | - public function getTaskSolution(); |
|
9 | + public function getTaskSolution(); |
|
10 | 10 | |
11 | 11 | } |
@@ -13,91 +13,91 @@ |
||
13 | 13 | use LaravelAnticaptcha\Anticaptcha\NoCaptchaProxyless; |
14 | 14 | |
15 | 15 | class AnticaptchaServiceProvider extends ServiceProvider { |
16 | - public $defer = true; |
|
16 | + public $defer = true; |
|
17 | 17 | |
18 | - public function boot() { |
|
19 | - $this->publishes( [ |
|
20 | - __DIR__ . '/../config/anticaptcha.php' => config_path( 'anticaptcha.php' ), |
|
21 | - ], 'anticaptcha' ); |
|
18 | + public function boot() { |
|
19 | + $this->publishes( [ |
|
20 | + __DIR__ . '/../config/anticaptcha.php' => config_path( 'anticaptcha.php' ), |
|
21 | + ], 'anticaptcha' ); |
|
22 | 22 | |
23 | - $this->mergeConfigFrom( |
|
24 | - __DIR__ . '/../config/anticaptcha.php', |
|
25 | - 'anticaptcha' |
|
26 | - ); |
|
23 | + $this->mergeConfigFrom( |
|
24 | + __DIR__ . '/../config/anticaptcha.php', |
|
25 | + 'anticaptcha' |
|
26 | + ); |
|
27 | 27 | |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | - public function register() { |
|
30 | + public function register() { |
|
31 | 31 | |
32 | - $this->app->singleton( NoCaptchaProxyless::class, function ( $app ) { |
|
33 | - $instance = new NoCaptchaProxyless(); |
|
34 | - $instance->setKey( config( 'anticaptcha.key' ) ); |
|
32 | + $this->app->singleton( NoCaptchaProxyless::class, function ( $app ) { |
|
33 | + $instance = new NoCaptchaProxyless(); |
|
34 | + $instance->setKey( config( 'anticaptcha.key' ) ); |
|
35 | 35 | |
36 | - return $instance; |
|
37 | - } ); |
|
36 | + return $instance; |
|
37 | + } ); |
|
38 | 38 | |
39 | - $this->app->singleton( NoCaptcha::class, function ( $app ) { |
|
40 | - $instance = new NoCaptcha(); |
|
41 | - $instance->setKey( config( 'anticaptcha.key' ) ); |
|
39 | + $this->app->singleton( NoCaptcha::class, function ( $app ) { |
|
40 | + $instance = new NoCaptcha(); |
|
41 | + $instance->setKey( config( 'anticaptcha.key' ) ); |
|
42 | 42 | |
43 | - return $instance; |
|
44 | - } ); |
|
43 | + return $instance; |
|
44 | + } ); |
|
45 | 45 | |
46 | - $this->app->singleton( ImageToText::class, function ( $app ) { |
|
47 | - $instance = new ImageToText(); |
|
48 | - $instance->setKey( config( 'anticaptcha.key' ) ); |
|
46 | + $this->app->singleton( ImageToText::class, function ( $app ) { |
|
47 | + $instance = new ImageToText(); |
|
48 | + $instance->setKey( config( 'anticaptcha.key' ) ); |
|
49 | 49 | |
50 | - return $instance; |
|
51 | - } ); |
|
50 | + return $instance; |
|
51 | + } ); |
|
52 | 52 | |
53 | - $this->app->singleton( GeeTestProxyless::class, function ( $app ) { |
|
54 | - $instance = new GeeTestProxyless(); |
|
55 | - $instance->setKey( config( 'anticaptcha.key' ) ); |
|
53 | + $this->app->singleton( GeeTestProxyless::class, function ( $app ) { |
|
54 | + $instance = new GeeTestProxyless(); |
|
55 | + $instance->setKey( config( 'anticaptcha.key' ) ); |
|
56 | 56 | |
57 | - return $instance; |
|
58 | - } ); |
|
57 | + return $instance; |
|
58 | + } ); |
|
59 | 59 | |
60 | - $this->app->singleton( GeeTest::class, function ( $app ) { |
|
61 | - $instance = new GeeTest(); |
|
62 | - $instance->setKey( config( 'anticaptcha.key' ) ); |
|
60 | + $this->app->singleton( GeeTest::class, function ( $app ) { |
|
61 | + $instance = new GeeTest(); |
|
62 | + $instance->setKey( config( 'anticaptcha.key' ) ); |
|
63 | 63 | |
64 | - return $instance; |
|
65 | - } ); |
|
64 | + return $instance; |
|
65 | + } ); |
|
66 | 66 | |
67 | - $this->app->singleton( FunCaptchaProxyless::class, function ( $app ) { |
|
68 | - $instance = new FunCaptchaProxyless(); |
|
69 | - $instance->setKey( config( 'anticaptcha.key' ) ); |
|
67 | + $this->app->singleton( FunCaptchaProxyless::class, function ( $app ) { |
|
68 | + $instance = new FunCaptchaProxyless(); |
|
69 | + $instance->setKey( config( 'anticaptcha.key' ) ); |
|
70 | 70 | |
71 | - return $instance; |
|
72 | - } ); |
|
71 | + return $instance; |
|
72 | + } ); |
|
73 | 73 | |
74 | - $this->app->singleton( FunCaptcha::class, function ( $app ) { |
|
75 | - $instance = new FunCaptcha(); |
|
76 | - $instance->setKey( config( 'anticaptcha.key' ) ); |
|
74 | + $this->app->singleton( FunCaptcha::class, function ( $app ) { |
|
75 | + $instance = new FunCaptcha(); |
|
76 | + $instance->setKey( config( 'anticaptcha.key' ) ); |
|
77 | 77 | |
78 | - return $instance; |
|
79 | - } ); |
|
78 | + return $instance; |
|
79 | + } ); |
|
80 | 80 | |
81 | - $this->app->singleton( CustomCaptcha::class, function ( $app ) { |
|
82 | - $instance = new CustomCaptcha(); |
|
83 | - $instance->setKey( config( 'anticaptcha.key' ) ); |
|
81 | + $this->app->singleton( CustomCaptcha::class, function ( $app ) { |
|
82 | + $instance = new CustomCaptcha(); |
|
83 | + $instance->setKey( config( 'anticaptcha.key' ) ); |
|
84 | 84 | |
85 | - return $instance; |
|
86 | - } ); |
|
85 | + return $instance; |
|
86 | + } ); |
|
87 | 87 | |
88 | - } |
|
88 | + } |
|
89 | 89 | |
90 | - public function provides() { |
|
91 | - return [ |
|
92 | - NoCaptchaProxyless::class, |
|
93 | - NoCaptcha::class, |
|
94 | - ImageToText::class, |
|
95 | - GeeTestProxyless::class, |
|
96 | - GeeTest::class, |
|
97 | - FunCaptchaProxyless::class, |
|
98 | - FunCaptcha::class, |
|
99 | - CustomCaptcha::class |
|
100 | - ]; |
|
101 | - } |
|
90 | + public function provides() { |
|
91 | + return [ |
|
92 | + NoCaptchaProxyless::class, |
|
93 | + NoCaptcha::class, |
|
94 | + ImageToText::class, |
|
95 | + GeeTestProxyless::class, |
|
96 | + GeeTest::class, |
|
97 | + FunCaptchaProxyless::class, |
|
98 | + FunCaptcha::class, |
|
99 | + CustomCaptcha::class |
|
100 | + ]; |
|
101 | + } |
|
102 | 102 | |
103 | 103 | } |