| 1 | 1 | ▶ | use File::Temp qw/tempfile/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | 1 | ▶ | use Webqq::Client::Util qw(console); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 0 | ▶ | sub Webqq::Client::_get_img_verify_code{ | ||||||||||||
|
Subroutine
_get_img_verify_code: not called CC=9 SCAR=45.0
| |||||||||||||||
| 4 | 0 | my $self = shift; | |||||||||||||
| 5 | 0 | ▶ | if ($self->{qq_param}{is_need_img_verifycode} == 0){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 6 | 0 | $self->{qq_param}{img_verifycode_source} = 'NONE'; | |||||||||||||
| 7 | 0 | return 1 ; | |||||||||||||
| 8 | } | ||||||||||||||
| 9 | 0 | my $ua = $self->{ua}; | |||||||||||||
| 10 | 0 | my $api_url = 'https://ssl.captcha.qq.com/getimage'; | |||||||||||||
| 11 | 0 | ▶ | my @headers = $self->{type} eq 'webqq'? (Referer => 'https://ui.ptlogin2.qq.com/cgi-bin/login?daid=164&target=self&style=5&mibao_css=m_webqq&appid=1003903&enable_qlogin=0&no_verifyimg=1&s_url=http%3A%2F%2Fweb2.qq.com%2Floginproxy.html&f_url=loginerroralert&strong_login=1&login_state=10&t=20140612002') | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 12 | : (Referer => 'https://ui.ptlogin2.qq.com/cgi-bin/login?daid=164&target=self&style=16&mibao_css=m_webqq&appid=501004106&enable_qlogin=0&no_verifyimg=1&s_url=http%3A%2F%2Fw.qq.com%2Fproxy.html&f_url=loginerroralert&strong_login=1&login_state=10&t=20131024001') | ||||||||||||||
| 13 | ; | ||||||||||||||
| 14 | my @query_string = ( | ||||||||||||||
| 15 | aid => $self->{qq_param}{g_appid}, | ||||||||||||||
| 16 | r => rand(), | ||||||||||||||
| 17 | uin => $self->{qq_param}{qq}, | ||||||||||||||
| 18 | cap_cd => $self->{qq_param}{cap_cd}, | ||||||||||||||
| 19 | 0 | ); | |||||||||||||
| 20 | |||||||||||||||
| 21 | 0 | my @query_string_pairs; | |||||||||||||
| 22 | 0 | ▶ | push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string) ; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 23 | |||||||||||||||
| 24 | 0 | ▶ | for(my $i=1;$i<=$self->{ua_retry_times};$i++){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 25 | 0 | my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers); | |||||||||||||
| 26 | 0 | ▶ | if($response->is_success){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 27 | 0 | my ($fh, $filename) = tempfile("webqq_img_verfiy_XXXX",SUFFIX =>".jpg",TMPDIR => 1); | |||||||||||||
| 28 | 0 | binmode $fh; | |||||||||||||
| 29 | 0 | print $fh $response->content(); | |||||||||||||
| 30 | 0 | close $fh; | |||||||||||||
| 31 | 0 | ▶ | if(-t STDIN){ | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 32 | 0 | console "请输入图片验证码 [ $filename ]: "; | |||||||||||||
| 33 | 0 | chomp($self->{qq_param}{verifycode} = <STDIN>); | |||||||||||||
| 34 | 0 | $self->{qq_param}{img_verifycode_source} = 'TTY'; | |||||||||||||
| 35 | } | ||||||||||||||
| 36 | elsif(ref $self->{on_input_img_verifycode} eq 'CODE'){ | ||||||||||||||
| 37 | 0 | my $code = $self->{on_input_img_verifycode}->($filename); | |||||||||||||
| 38 | 0 | ▶ | if(defined $code){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 39 | 0 | $self->{qq_param}{verifycode} = $code; | |||||||||||||
| 40 | 0 | $self->{qq_param}{img_verifycode_source} = 'CALLBACK'; | |||||||||||||
| 41 | } | ||||||||||||||
| 42 | 0 | else{console "无法从回调函数中获取有效的验证码,客户端终止\n";$self->stop();} | |||||||||||||
| 43 | } | ||||||||||||||
| 44 | else{ | ||||||||||||||
| 45 | 0 | console "STDIN未连接到tty,无法输入验证码,客户端终止...\n"; | |||||||||||||
| 46 | 0 | $self->stop(); | |||||||||||||
| 47 | } | ||||||||||||||
| 48 | 0 | return 1; | |||||||||||||
| 49 | } | ||||||||||||||
| 50 | } | ||||||||||||||
| 51 | 0 | return 0; | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | 1 | 1; | |||||||||||||