| 1 | package WebService::AntiCaptcha; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use 5.008_005; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | our $VERSION = '0.02'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | use Carp 'croak'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 1 | ▶ | use URI; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 1 | ▶ | use MIME::Base64; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 1 | ▶ | use JSON; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 1 | ▶ | use vars qw/$errstr/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 0 | ▶ | sub errstr { $errstr } | ||||||||||||||||||
|
Subroutine
errstr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||
| 17 | 0 | my $class = shift; | |||||||||||||||||||
| 18 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 0 | ▶ | $args{clientKey} or croak "clientKey is required.\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | 0 | ▶ | $args{ua} ||= LWP::UserAgent->new; | ||||||||||||||||||
|
Condition0%0/3
$args{"ua"} ||= "LWP::UserAgent"->new
MC/DC0%0/2
$args{"ua"} ||= "LWP::UserAgent"->new
$args{"ua"}
"LWP::UserAgent"->new
Truth table0%0/3
A ||= B
A= $args{"ua"}B= "LWP::UserAgent"->new
| |||||||||||||||||||||
| 22 | 0 | ▶ | $args{url} ||= 'https://api.anti-captcha.com/'; | ||||||||||||||||||
|
Condition0%0/2
$args{"url"} ||= "https://api.anti-captcha.com/"
MC/DC0%0/1
$args{"url"} ||= "https://api.anti-captcha.com/"
$args{"url"}
Truth table0%0/2
A
A= $args{"url"}
| |||||||||||||||||||||
| 23 | 0 | ▶ | $args{sleep} ||= 3; | ||||||||||||||||||
|
Condition0%0/2
$args{"sleep"} ||= 3
MC/DC0%0/1
$args{"sleep"} ||= 3
$args{"sleep"}
Truth table0%0/2
A
A= $args{"sleep"}
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 0 | return bless \%args, $class; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | sub createTask { | ||||||||||||||||||
|
Subroutine
createTask: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 29 | 0 | my ($self, $task, $softId, $languagePool) = @_; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 0 | ▶ | $self->request('createTask', | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 32 | task => $task, | ||||||||||||||||||||
| 33 | $softId ? (softId => $softId) : (), | ||||||||||||||||||||
| 34 | $languagePool ? (languagePool => $languagePool) : (), | ||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | ▶ | sub getTaskResult { | ||||||||||||||||||
|
Subroutine
getTaskResult: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 39 | 0 | my ($self, $taskId) = @_; | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | $self->request('getTaskResult', taskId => $taskId); | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | sub getBalance { | ||||||||||||||||||
|
Subroutine
getBalance: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 45 | 0 | my ($self) = @_; | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | $self->request('getBalance'); | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | ▶ | sub getQueueStats { | ||||||||||||||||||
|
Subroutine
getQueueStats: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 51 | 0 | my ($self, $queueId) = @_; | |||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 0 | $self->request('getQueueStats', queueId => $queueId); | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | ▶ | sub reportIncorrectImageCaptcha { | ||||||||||||||||||
|
Subroutine
reportIncorrectImageCaptcha: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 57 | 0 | my ($self, $taskId) = @_; | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | $self->request('reportIncorrectImageCaptcha', taskId => $taskId); | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | sub request { | ||||||||||||||||||
|
Subroutine
request: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 63 | 0 | my ($self, $url, %params) = @_; | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | $params{clientKey} = $self->{clientKey}; | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | my $res = $self->{ua}->post($self->{url} . $url, | |||||||||||||||||||
| 68 | 'Accept' => 'application/json', | ||||||||||||||||||||
| 69 | 'Content-Type' => 'application/json', | ||||||||||||||||||||
| 70 | 'Content' => encode_json(\%params), | ||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | # print Dumper(\$res); use Data::Dumper; | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 0 | ▶ | unless ($res->is_success) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 0 | $errstr = "Failed to post $url: " . $res->status_line; | |||||||||||||||||||
| 77 | 0 | return; | |||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | 0 | return decode_json($res->decoded_content); | |||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 1 | 1; | |||||||||||||||||||
| 83 | __END__ | ||||||||||||||||||||