Webqq/Client/Remote/_relink.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 1 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 49 CC 11 SCAR 48.8
CC
11
Cov
0%
Mojo::Webqq::Client::_relink
132.0
CRAP 132.0
1 sub Mojo::Webqq::Client::_relink{
2 my $self = shift;
3 $self->login_state('relink');
4 $self->info("正在进行重新连接(2)...");
5 my $api_url = 'http://d1.web2.qq.com/channel/login2';
6 my $headers = {Referer=>'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2',json=>1};
7 my %r = (
8 status => $self->mode,
9 key => "",
10 ptwebqq => $self->ptwebqq,
11 clientid => $self->clientid,
12 psessionid => $self->psessionid,
13 );
14
15 my $data = $self->http_post($api_url,$headers,form=>{r=>$self->to_json(\%r)});
16 unless(defined $data){
17 $self->relogin();
18 return 0;
19 }
20 if($data->{retcode} ==0){
21 $self->psessionid($data->{result}{psessionid}) if $data->{result}{psessionid};
22 $self->vfwebqq($data->{result}{vfwebqq}) if $data->{result}{vfwebqq};
23 $self->clientid($data->{result}{clientid}) if $data->{result}{clientid};
24 $self->ptwebqq($data->{result}{ptwebqq}) if $data->{result}{ptwebqq};
25 $self->skey($data->{result}{skey}) if $data->{result}{skey};
26 my @cookies;
27 push @cookies,Mojo::Cookie::Response->new(
28 name => "ptwebqq",
29 value => $data->{result}{ptwebqq},
30 domain => "qq.com",
31 path => "/",
32 ) 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 ) if defined $data->{result}{skey};
39 $self->ua->cookie_jar->add(@cookies) if @cookies;
40 $self->save_cookie();
41 $self->_cookie_proxy();
42 $self->login_state('success');
43 $self->info("重新连接(2)成功");
44 return 1;
45 }
46 else{
47 $self->relogin();
48 return 0;
49 }
50 }
51 1;