Issues (21)

src/examples/exampleGeetestTicketmaster.php (1 issue)

1
<?php
2
namespace LaravelAnticaptcha\Anticaptcha;
3
4
$api = new GeeTestProxyless();
5
$api->setVerboseMode(true);
6
7
echo "\nThis example will solve captcha from  https://www.ticketmaster.com/\n\n";
8
9
//your anti-captcha.com account key
10
$api->setKey(readline("You API key: "));
11
12
echo "grabbing challenge key ... \n";
13
$challenge = getChallenge();
14
15
if ($challenge == "") {
16
    echo "something went wrong, probably example was changed or network is inaccessible\n";
17
    exit;
18
}
19
20
21
echo "setting gt=ce33de396f8d04030f6eca8fbd225070, challenge=$challenge\n";
22
23
$api->setWebsiteURL("https://www.ticketmaster.com/");
24
$api->setGTKey("ce33de396f8d04030f6eca8fbd225070");
25
$api->setChallenge($challenge);
26
27
//setting custom geetest api subdomain
28
$api->setAPISubdomain("api-na.geetest.com");
29
30
31
if (!$api->createTask()) {
32
    $api->debout("API v2 send failed - ".$api->getErrorMessage(), "red");
33
    return false;
34
}
35
36
$taskId = $api->getTaskId();
37
38
39
if (!$api->waitForResult()) {
40
    $api->debout("could not solve captcha", "red");
41
    $api->debout($api->getErrorMessage());
42
} else {
43
    echo "solution: \n";
44
    print_r($api->getTaskSolution());
45
}
46
47
48
function getChallenge() {
49
    
50
    
51
    $ch = curl_init();
52
    curl_setopt($ch, CURLOPT_URL, "https://www.ticketmaster.com/distil_r_captcha_challenge");
53
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
54
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
55
        "Accept: text/html,application/xhtml+xml,application/xml;q=0.9;q=0.8",
56
        "Accept-Encoding: deflate",
57
        "Accept-Language: en-US,en;q=0.5",
58
        "Cache-Control: max-age=0",
59
        "Connection: keep-alive",
60
        "Host: www.ticketmaster.com"
61
    ]);
62
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:50.0) Gecko/20100101 Firefox/50.0");
63
    curl_setopt($ch, CURLOPT_HEADER, 0);
64
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
65
    $result = curl_exec($ch);
66
    $curlError = curl_error($ch);
67
    curl_close($ch);
68
    
69
    if ($curlError != "") {
70
        echo "Got HTTP error: $curlError\n";
71
        exit;
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
72
    }
73
    return substr($result, 0, strpos($result, ";"));
74
    
75
}
76
77
78