File Coverage

blib/lib/Webqq/Client/Method/_login2.pm
Criterion Covered Total %
statement 6 27 22.2
branch 0 10 0.0
condition n/a
subroutine 2 3 66.6
pod n/a
total 8 40 20.0


line stmt bran cond sub pod time code
1 1     1   5 use JSON ;
  1         1  
  1         37  
2 1     1   121 use Webqq::Client::Util qw(console);
  1         1  
  1         249  
3             sub Webqq::Client::_login2{
4 0     0     my $self = shift;
5 0           console "尝试进行登录(阶段2)...\n";
6 0           my $ua = $self->{ua};
7 0           my $api_url = 'http://d.web2.qq.com/channel/login2';
8 0 0         my @headers = $self->{type} eq 'webqq'? (Referer=>'http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=3')
9             : (Referer=>'http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2')
10             ;
11 0           my %r = (
12             status => $self->{qq_param}{state},
13             ptwebqq => $self->{qq_param}{ptwebqq},
14             clientid => $self->{qq_param}{clientid},
15             psessionid => $self->{qq_param}{psessionid},
16             );
17            
18 0 0         if($self->{type} eq 'webqq'){
19 0           $r{passwd_sig} = $self->{qq_param}{passwd_sig};
20             }
21              
22 0           for(my $i=0;$i<=$self->{ua_retry_times};$i++){
23 0           my $response = $ua->post($api_url,[r=>JSON->new->utf8->encode(\%r)], @headers);
24 0 0         if($response->is_success){
25 0 0         print $response->content() if $self->{debug};
26 0           my $content = $response->content();
27 0           my $data = JSON->new->utf8->decode($content);
28 0 0         if($data->{retcode} ==0){
29 0           $self->{qq_param}{psessionid} = $data->{result}{psessionid};
30 0           $self->{qq_param}{vfwebqq} = $data->{result}{vfwebqq};
31 0           $self->_cookie_proxy();
32 0           $self->{login_state} = 'success';
33 0           return 1;
34             }
35             }
36             }
37 0           return 0;
38             }
39             1;