Webqq/Client/Method/change_state.pm

filter: Statementstmt 29.1% 7 / 24 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 26.3% 10 / 38 CC 6 SCAR 34.6
CC
6
Cov
21%
change_state
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 31.8
« Webqq/Client/Method/_prepare_for_login.pm ↑ Summary Plack/Middleware/Openqq/SelfTalkForbid.pm »
1 1 ▶use JSON;
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::change_state{
Subroutine change_state: not called CC=6 SCAR=37.4
Pod documented
4 0 my $self = shift;
5 0 ▶ return undef if $self->{type} ne 'smartqq';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"type"} ne "smartqq" 0 0 0
6 0 my $state = shift;
7 0 my $api_url = 'http://d.web2.qq.com/channel/change_status2';
8 0 my $ua = $self->{ua};
9 0 my @headers = (
10 Referer=>'http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2'
11 );
12 my @query_string = (
13 newstatus => $state,
14 clientid => $self->{qq_param}{clientid},
15 psessionid => $self->{qq_param}{psessionid},
16 0 t => time,
17 );
18  
19 0 my @query_string_pairs;
20 0 ▶ push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string);
Branch: 1 branch
BranchTrueFalseTotal
@query_string and do { push @query_string_pairs, shift(@query_string) . '=' . shift(@query_string) } 0 0 0
21 0 my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers);
22 0 ▶ if($response->is_success){
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success) { } 0 0 0
23 0 ▶ print $response->content(),"\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
24 0 my $json = JSON->new->utf8->decode( $response->content() );
25 0 ▶ return undef if $json->{retcode} !=0;
Branch: 1 branch
BranchTrueFalseTotal
if $json->{"retcode"} != 0 0 0 0
26 0 console "登录状态已修改为:$state\n";
27 0 return $state;
28 }
29 0 else{return undef}
30 }
31 1 1;
« Webqq/Client/Method/_prepare_for_login.pm ↑ Summary Plack/Middleware/Openqq/SelfTalkForbid.pm »