Skip to content

Commit fc1592e

Browse files
added task pushvariables feature
1 parent 0aa98a0 commit fc1592e

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

Diff for: lib/imagetyperzapi.rb

+33
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
TIKTOK_ENDPOINT = 'http://captchatypers.com/captchaapi/UploadTikTokCaptchaUser.ashx'
2525
FUNCAPTCHA_ENDPOINT = 'http://captchatypers.com/captchaapi/UploadFunCaptcha.ashx'
2626
TASK_ENDPOINT = 'http://captchatypers.com/captchaapi/UploadCaptchaTask.ashx'
27+
TASK_PUSH_ENDPOINT = 'http://captchatypers.com/CaptchaAPI/SaveCaptchaPush.ashx'
2728

2829
CAPTCHA_ENDPOINT_CONTENT_TOKEN = '/Forms/UploadFileAndGetTextNEWToken.ashx'
2930
CAPTCHA_ENDPOINT_URL_TOKEN = '/Forms/FileUploadAndGetTextCaptchaURLToken.ashx'
@@ -557,6 +558,38 @@ def account_balance
557558
return "$#{response_text}" # all good, return
558559
end
559560

561+
# set captcha bad
562+
def task_push_variables(captcha_id, variables)
563+
data = {
564+
"action": "GETTEXT",
565+
"captchaid": captcha_id.to_s,
566+
"pushVariables": JSON.generate(variables)
567+
}
568+
569+
if !@_username.empty?
570+
data["username"] = @_username
571+
data["password"] = @_password
572+
else
573+
data["token"] = @_access_token
574+
end
575+
url = TASK_PUSH_ENDPOINT
576+
577+
# make request
578+
http = Net::HTTP.new(ROOT_DOMAIN, 80)
579+
http.read_timeout = @_timeout
580+
req = Net::HTTP::Post.new(url, @_headers)
581+
res = http.request(req, URI.encode_www_form(data))
582+
response_text = res.body # get response body
583+
584+
# check if error
585+
if response_text.include?("ERROR:")
586+
response_err = response_text.split('ERROR:')[1].strip # get only the
587+
@_error = response_err
588+
raise @_error
589+
end
590+
response_text # all good, return
591+
end
592+
560593
# set captcha bad
561594
def set_captcha_bad(captcha_id)
562595
data = {

Diff for: readme.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ imagetyperzapi is a super easy to use bypass captcha API wrapper for imagetyperz
55

66
## Installation
77
gem "imagetyperzapi", :git => "git://github.com/imagetyperz-api/imagetyperz-api-ruby.git"
8-
8+
99
or
1010

1111
git clone https://github.com/imagetyperz-api/imagetyperz-api-ruby
@@ -222,6 +222,21 @@ d = {
222222
captcha_id = ita.submit_task d
223223
```
224224

225+
#### Task pushVariables
226+
227+
Update a variable value while task is running. Useful when dealing with 2FA authentication.
228+
229+
When template reaches an action that uses a variable which wasn't provided with the submission of the task,
230+
task (while running on worker machine) will wait for variable to be updated through push.
231+
232+
You can use the pushVariables method as many times as you need, even overwriting previously set variables.
233+
234+
```ruby
235+
ita.task_push_variables captcha_id, {"twofactor_code": code}
236+
```
237+
238+
239+
225240
## Retrieve response
226241

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

Diff for: task.rb

+6
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ def test_api
2121
# 'user_agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0', # optional
2222
}
2323

24+
2425
captcha_id = ita.submit_task d
2526
# submit image captcha, and check for solution
2627
puts "Waiting for captcha to be solved..."
28+
29+
# send pushVariable - update of variable while task is running (e.g 2FA code)
30+
# ------------------------------------------------------------------------------
31+
# ita.task_push_variables captcha_id, {"twofactor_code": code}
32+
2733
response = nil
2834
while response == nil
2935
sleep 10

0 commit comments

Comments
 (0)