File Coverage

blib/lib/Mojo/Webqq/Client/Remote/_relink.pm
Criterion Covered Total %
statement 0 27 0.0
branch 0 20 0.0
condition n/a
subroutine 0 1 0.0
pod n/a
total 0 48 0.0


line stmt bran cond sub pod time code
1             sub Mojo::Webqq::Client::_relink{
2 0     0     my $self = shift;
3 0           $self->login_state('relink');
4 0           $self->info("正在进行重新连接(2)...");
5 0           my $api_url = 'http://d1.web2.qq.com/channel/login2';
6 0           my $headers = {Referer=>'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2',json=>1};
7 0           my %r = (
8             status => $self->mode,
9             key => "",
10             ptwebqq => $self->ptwebqq,
11             clientid => $self->clientid,
12             psessionid => $self->psessionid,
13             );
14            
15 0           my $data = $self->http_post($api_url,$headers,form=>{r=>$self->to_json(\%r)});
16 0 0         unless(defined $data){
17 0           $self->relogin();
18 0           return 0;
19             }
20 0 0         if($data->{retcode} ==0){
21 0 0         $self->psessionid($data->{result}{psessionid}) if $data->{result}{psessionid};
22 0 0         $self->vfwebqq($data->{result}{vfwebqq}) if $data->{result}{vfwebqq};
23 0 0         $self->clientid($data->{result}{clientid}) if $data->{result}{clientid};
24 0 0         $self->ptwebqq($data->{result}{ptwebqq}) if $data->{result}{ptwebqq};
25 0 0         $self->skey($data->{result}{skey}) if $data->{result}{skey};
26 0           my @cookies;
27             push @cookies,Mojo::Cookie::Response->new(
28             name => "ptwebqq",
29             value => $data->{result}{ptwebqq},
30             domain => "qq.com",
31             path => "/",
32 0 0         ) if defined $data->{result}{ptwebqq};
33             push @cookies,Mojo::Cookie::Response->new(
34             name => "skey",
35             value => $data->{result}{skey},
36             domain => "qq.com",
37             path => "/",
38 0 0         ) if defined $data->{result}{skey};
39 0 0         $self->ua->cookie_jar->add(@cookies) if @cookies;
40 0           $self->save_cookie();
41 0           $self->_cookie_proxy();
42 0           $self->login_state('success');
43 0           $self->info("重新连接(2)成功");
44 0           return 1;
45             }
46             else{
47 0           $self->relogin();
48 0           return 0;
49             }
50             }
51             1;