-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
68 lines (59 loc) · 2.47 KB
/
example.php
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
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/php
<?php
// ----------------------------------------
// Imagetypers API example
// ----------------------------------------
require('lib/imagetyperzapi.php'); // load API library
// Test method
function test_api() {
$access_token = 'your_access_token_here';
$i = new ImagetyperzAPI($access_token); // init API lib obj
//legacy (will get deprecated at some point)
//$i->set_user_password('your_username', 'your_password');
// check account balance
// --------------------------
$balance = $i->account_balance(); // get balance
echo "Balance: $balance";
// works
echo 'Solving captcha ...';
$captcha_text = $i->solve_captcha('captcha.jpg');
echo "Captcha text: $captcha_text";
die('here');
// solve recaptcha
// --------------------------------------------------------------------
// check: http://www.imagetyperz.com/Forms/recaptchaapi.aspx on how to get page_url and googlekey
$page_url = 'your_page_url_here';
$sitekey = 'your_sitekey_here';
echo 'Submitting recaptcha...';
$captcha_id = $i->submit_recaptcha($page_url, $sitekey);
echo 'Waiting for recaptcha to be completed ...';
//echo 'Waiting for recaptcha to be solved ...';
// check every 10 seconds if recaptcha was solved
while ($i->in_progress($captcha_id))
sleep(10);
// completed at this point
$recaptcha_response = $i->retrieve_recaptcha($captcha_id);
echo "Recaptcha response: $recaptcha_response";
// Other examples
// -----------------
// $i = new ImagetypersAPI($access_token, 123); // use affiliateid
// $i = new ImagetypersAPI($access_token, 123, 60); // affiliate id and 60 seconds timeout
// submit recaptcha with proxy from which it will be solved
// $captcha_id = $i->submit_recaptcha($page_url, $sitekey, "12.34.45.78:1234");
// $captcha_id = $i->submit_recaptcha($page_url, $sitekey, "12.34.45.78:1234:user:pass"); // proxy authentication
// echo $i->set_captcha_bad($captcha_id); // set captcha bad
// getters
// echo $i->recaptcha_id(); // get last recaptcha id
// echo $i->recaptcha_response(); // get last recaptcha response
// echo $i->error(); // get last error
}
// Main method
function main() {
try {
test_api(); // test API
} catch (Exception $ex) {
echo "Error occured: " . $ex->getMessage(); // print error
}
}
main(); // run main function
?>