1 | <?php |
||
13 | class Client extends GenericClient |
||
14 | { |
||
15 | const STATUS_OK_REPORT_RECORDED = 'OK_REPORT_RECORDED'; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $serverBaseUri = 'http://rucaptcha.com'; |
||
21 | |||
22 | /** |
||
23 | * Your application ID in Rucaptcha catalog. |
||
24 | * The value `1013` is ID of this library. Set in false if you want to turn off sending any ID. |
||
25 | * |
||
26 | * @see https://rucaptcha.com/software/view/php-api-client |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $softId = '1013'; |
||
30 | |||
31 | /** |
||
32 | * @inheritdoc |
||
33 | */ |
||
34 | public function sendCaptcha($content, array $extra = []) |
||
41 | |||
42 | /** |
||
43 | * Bulk captcha result. |
||
44 | * |
||
45 | * @param int[] $captchaIds # Captcha task Ids array |
||
46 | * @return string[] # Array $captchaId => $captchaText or false if is not ready |
||
47 | * @throws ErrorResponseException |
||
48 | */ |
||
49 | public function getCaptchaResultBulk(array $captchaIds) |
||
73 | |||
74 | /** |
||
75 | * Returns balance of account. |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | public function getBalance() |
||
87 | |||
88 | /** |
||
89 | * Report of wrong recognition. |
||
90 | * |
||
91 | * @param string $captchaId |
||
92 | * @return bool |
||
93 | * @throws ErrorResponseException |
||
94 | */ |
||
95 | public function badCaptcha($captchaId) |
||
112 | |||
113 | /** |
||
114 | * Returns server health data. |
||
115 | * |
||
116 | * @param string|string[] $paramsList # List of metrics to be returned |
||
117 | * @return array # Array of load metrics $metric => $value formatted |
||
118 | */ |
||
119 | public function getLoad($paramsList = ['waiting', 'load', 'minbid', 'averageRecognitionTime']) |
||
135 | |||
136 | /** |
||
137 | * Returns load data as XML. |
||
138 | * |
||
139 | * @return \SimpleXMLElement |
||
140 | */ |
||
141 | public function getLoadXml() |
||
149 | |||
150 | /** |
||
151 | * @param string $captchaId # Captcha task ID |
||
152 | * @return array | false # Solved captcha and cost array or false if captcha is not ready |
||
153 | * @throws ErrorResponseException |
||
154 | */ |
||
155 | public function getCaptchaResultWithCost($captchaId) |
||
181 | |||
182 | /** |
||
183 | * Add pingback url to rucaptcha whitelist. |
||
184 | * |
||
185 | * @param string $url |
||
186 | * @return bool # true if added and exception if fail |
||
187 | * @throws ErrorResponseException |
||
188 | */ |
||
189 | public function addPingback($url) |
||
206 | |||
207 | /** |
||
208 | * Returns pingback whitelist items. |
||
209 | * |
||
210 | * @return string[] # List of urls |
||
211 | * @throws ErrorResponseException |
||
212 | */ |
||
213 | public function getPingbacks() |
||
232 | |||
233 | /** |
||
234 | * Remove pingback url from whitelist. |
||
235 | * |
||
236 | * @param string $uri |
||
237 | * @return bool |
||
238 | * @throws ErrorResponseException |
||
239 | */ |
||
240 | public function deletePingback($uri) |
||
256 | |||
257 | /** |
||
258 | * Truncate pingback whitelist. |
||
259 | * |
||
260 | * @return bool |
||
261 | * @throws ErrorResponseException |
||
262 | */ |
||
263 | public function deleteAllPingbacks() |
||
267 | |||
268 | /** |
||
269 | * Match error code by response. |
||
270 | * |
||
271 | * @param string $responseText |
||
272 | * @return int |
||
273 | */ |
||
274 | private function getErrorCode($responseText) |
||
281 | } |
||
282 |