Skip to content

Commit 02be846

Browse files
added task pushvariables feature
1 parent 2716af3 commit 02be846

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

Diff for: lib/imagetyperzapi.php

+28
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
define('TIKTOK_ENDPOINT', 'http://captchatypers.com/captchaapi/UploadTikTokCaptchaUser.ashx');
1717
define('FUNCAPTCHA_ENDPOINT', 'http://captchatypers.com/captchaapi/UploadFunCaptcha.ashx');
1818
define('TASK_ENDPOINT', 'http://captchatypers.com/captchaapi/UploadCaptchaTask.ashx');
19+
define('TASK_PUSH_ENDPOINT', 'http://captchatypers.com/CaptchaAPI/SaveCaptchaPush.ashx');
1920

2021
define('CAPTCHA_ENDPOINT_CONTENT_TOKEN', 'http://captchatypers.com/Forms/UploadFileAndGetTextNEWToken.ashx');
2122
define('CAPTCHA_ENDPOINT_URL_TOKEN', 'http://captchatypers.com/Forms/FileUploadAndGetTextCaptchaURLToken.ashx');
@@ -521,6 +522,33 @@ function account_balance() {
521522

522523
return '$' . $response; // return response
523524
}
525+
526+
// Push variables for task
527+
function task_push_variables($captcha_id, $variables) {
528+
// set data array
529+
$data = array(
530+
"action" => "GETTEXT",
531+
"captchaid" => $captcha_id,
532+
"pushVariables" => json_encode($variables)
533+
);
534+
535+
if (!empty($this->_username)) {
536+
$data["username"] = $this->_username;
537+
$data["password"] = $this->_password;
538+
} else {
539+
$data['token'] = $this->_access_token;
540+
}
541+
$url = TASK_PUSH_ENDPOINT;
542+
543+
// do request
544+
$response = Utils::post($url, $data, USER_AGENT, $this->_timeout);
545+
// parse response
546+
if (strpos($response, 'ERROR:') !== false) {
547+
throw new Exception(trim(explode('ERROR:', $response)[1]));
548+
}
549+
550+
return $response; // return response
551+
}
524552

525553
// Set captcha bad
526554
function set_captcha_bad($captcha_id) {

Diff for: readme.md

+13
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,19 @@ $params['variables'] = array(
231231
$captcha_id = $i->submit_task($params);
232232
```
233233

234+
#### Task pushVariable
235+
Update a variable value while task is running. Useful when dealing with 2FA authentication.
236+
237+
When template reaches an action that uses a variable which wasn't provided with the submission of the task,
238+
task (while running on worker machine) will wait for variable to be updated through push.
239+
240+
You can use the pushVariables method as many times as you need, even overwriting previously set variables.
241+
```php
242+
$i->task_push_variables($captcha_id, array(
243+
"twofactor_code" => "39283"
244+
));
245+
```
246+
234247
## Retrieve response
235248

236249
Regardless of the captcha type (and method) used in submission of the captcha, this method is used

Diff for: task.php

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ function test_api() {
2424
//$params['user_agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0'; // - optional
2525
$captcha_id = $i->submit_task($params);
2626
echo "Waiting for captcha to be solved...\n";
27+
28+
// send pushVariable - update of variable while task is running (e.g 2FA code)
29+
// $i->task_push_variables($Ccaptcha_id, array(
30+
// "twofactor_code" => "39283"
31+
// ));
32+
2733
$response = null;
2834
while($response === null) {
2935
sleep(10);

0 commit comments

Comments
 (0)