forked from imagetyperz-api/imagetyperz-api-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.rb
More file actions
executable file
·55 lines (45 loc) · 1.6 KB
/
Copy pathexample.rb
File metadata and controls
executable file
·55 lines (45 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/ruby
# Imagetypers API test
load "lib/imagetyperzapi.rb"
def test_api
access_token = "your_access_token_here"
ita = ImageTyperzAPI.new(access_token, 1, 1)
# legacy way, will get deprecated at some point
ita.set_user_and_password('testingfor', 'testingfor')
# check account balance
# ---------------------------------------------------
balance = ita.account_balance # get balance
puts "Account balance: #{balance}" # print balance
# solve classic captcha
# ----------------------
puts "Solving captcha ... "
captcha_text = ita.solve_captcha'captcha.jpg'
puts "Captcha text: #{captcha_text}"
# recaptcha
# ---------------------------------------------------
# submit to server and get the id
captcha_id = ita.submit_recaptcha "page_url_here","sitekey_here"
puts "Waiting for recaptcha to be solved ..."
while ita.in_progress captcha_id # while it"s still in progress
sleep 10 # sleep for 10 seconds
end
# get the response and print it
recaptcha_response = ita.retrieve_recaptcha captcha_id # retrieve response
puts "Recaptcha response: #{recaptcha_response}"
# Other examples
# ---------------------------------------------------
# ita = ImageTyperzAPI.new(access_token, 1234) # with affiliate id
#puts ita.recaptcha_id
#puts ita.recaptcha_response
#ita.set_recaptcha_proxy"123.45.67.78:8080"
#ita.set_recaptcha_proxy"123.45.67.78:8080:user:password" # proxy with auth
#print ita.set_captcha_bad"123" # set captcha bad
end
def main
begin
test_api()
rescue => details
puts "[!] Error occured: #{details}"
end
end
main