@@ -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 |
@@ -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 | } |
@@ -127,20 +127,20 @@ |
||
127 | 127 | |
128 | 128 | |
129 | 129 | $ch = curl_init(); |
130 | - curl_setopt($ch,CURLOPT_URL,"{$this->scheme}://{$this->host}/$methodName"); |
|
131 | - curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); |
|
132 | - curl_setopt($ch,CURLOPT_ENCODING,"gzip,deflate"); |
|
133 | - curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST"); |
|
130 | + curl_setopt($ch, CURLOPT_URL, "{$this->scheme}://{$this->host}/$methodName"); |
|
131 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
132 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate"); |
|
133 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
134 | 134 | $postDataEncoded = json_encode($postData); |
135 | - curl_setopt($ch,CURLOPT_POSTFIELDS,$postDataEncoded); |
|
136 | - curl_setopt($ch,CURLOPT_HTTPHEADER, array( |
|
135 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $postDataEncoded); |
|
136 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
137 | 137 | 'Content-Type: application/json; charset=utf-8', |
138 | 138 | 'Accept: application/json', |
139 | - 'Content-Length: ' . strlen($postDataEncoded) |
|
139 | + 'Content-Length: '.strlen($postDataEncoded) |
|
140 | 140 | )); |
141 | - curl_setopt($ch,CURLOPT_TIMEOUT,30); |
|
142 | - curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,30); |
|
143 | - $result =curl_exec($ch); |
|
141 | + curl_setopt($ch, CURLOPT_TIMEOUT, 30); |
|
142 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); |
|
143 | + $result = curl_exec($ch); |
|
144 | 144 | $curlError = curl_error($ch); |
145 | 145 | |
146 | 146 | if ($curlError != "") { |
@@ -156,7 +156,9 @@ |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | public function debout($message, $color = "white") { |
159 | - if (!$this->verboseMode) return false; |
|
159 | + if (!$this->verboseMode) { |
|
160 | + return false; |
|
161 | + } |
|
160 | 162 | if ($color != "white" and $color != "") { |
161 | 163 | $CLIcolors = array( |
162 | 164 | "cyan" => "0;36", |
@@ -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 | } |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | function getChallenge() { |
49 | 49 | |
50 | 50 | |
51 | - $ch=curl_init(); |
|
52 | - curl_setopt($ch,CURLOPT_URL, "https://www.ticketmaster.com/distil_r_captcha_challenge"); |
|
53 | - curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); |
|
54 | - curl_setopt($ch,CURLOPT_HTTPHEADER, [ |
|
51 | + $ch = curl_init(); |
|
52 | + curl_setopt($ch, CURLOPT_URL, "https://www.ticketmaster.com/distil_r_captcha_challenge"); |
|
53 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
54 | + curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
|
55 | 55 | "Accept: text/html,application/xhtml+xml,application/xml;q=0.9;q=0.8", |
56 | 56 | "Accept-Encoding: deflate", |
57 | 57 | "Accept-Language: en-US,en;q=0.5", |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | "Connection: keep-alive", |
60 | 60 | "Host: www.ticketmaster.com" |
61 | 61 | ]); |
62 | - curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:50.0) Gecko/20100101 Firefox/50.0"); |
|
63 | - curl_setopt($ch,CURLOPT_HEADER,0); |
|
64 | - curl_setopt($ch,CURLOPT_TIMEOUT,10); |
|
65 | - $result =curl_exec($ch); |
|
62 | + curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:50.0) Gecko/20100101 Firefox/50.0"); |
|
63 | + curl_setopt($ch, CURLOPT_HEADER, 0); |
|
64 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
65 | + $result = curl_exec($ch); |
|
66 | 66 | $curlError = curl_error($ch); |
67 | 67 | curl_close($ch); |
68 | 68 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | echo "Got HTTP error: $curlError\n"; |
71 | 71 | exit; |
72 | 72 | } |
73 | - return substr($result, 0, strpos($result,";")); |
|
73 | + return substr($result, 0, strpos($result, ";")); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 |
@@ -23,6 +23,6 @@ |
||
23 | 23 | $api->debout("could not solve captcha", "red"); |
24 | 24 | $api->debout($api->getErrorMessage()); |
25 | 25 | } else { |
26 | - $recaptchaToken = $api->getTaskSolution(); |
|
26 | + $recaptchaToken = $api->getTaskSolution(); |
|
27 | 27 | echo "\ntoken result: $recaptchaToken\n\n"; |
28 | 28 | } |
@@ -22,6 +22,6 @@ |
||
22 | 22 | $api->debout("could not solve captcha", "red"); |
23 | 23 | $api->debout($api->getErrorMessage()); |
24 | 24 | } else { |
25 | - $captchaText = $api->getTaskSolution(); |
|
25 | + $captchaText = $api->getTaskSolution(); |
|
26 | 26 | echo "\nresult: $captchaText\n\n"; |
27 | 27 | } |
@@ -66,7 +66,7 @@ |
||
66 | 66 | $api->debout("could not solve captcha", "red"); |
67 | 67 | $api->debout($api->getErrorMessage()); |
68 | 68 | } else { |
69 | - $answers = $api->getTaskSolution(); |
|
69 | + $answers = $api->getTaskSolution(); |
|
70 | 70 | foreach ($answers as $key => $value) { |
71 | 71 | echo "answer for question '$key' : '$value'\n"; |
72 | 72 | } |
@@ -21,8 +21,8 @@ |
||
21 | 21 | exit; |
22 | 22 | } |
23 | 23 | |
24 | -$challenge = $data["challenge"]; |
|
25 | -$gt = $data["gt"]; |
|
24 | +$challenge = $data["challenge"]; |
|
25 | +$gt = $data["gt"]; |
|
26 | 26 | |
27 | 27 | echo "setting gt=$gt, challenge=$challenge\n"; |
28 | 28 |
@@ -33,6 +33,6 @@ |
||
33 | 33 | $api->debout("could not solve captcha", "red"); |
34 | 34 | $api->debout($api->getErrorMessage()); |
35 | 35 | } else { |
36 | - $recaptchaToken = $api->getTaskSolution(); |
|
36 | + $recaptchaToken = $api->getTaskSolution(); |
|
37 | 37 | echo "\ntoken result: $recaptchaToken\n\n"; |
38 | 38 | } |