Webqq/Client/Method/get_single_long_nick.pm

filter: Statementstmt 26.9% 7 / 26 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 23.8% 10 / 42 CC 7 SCAR 37.8
CC
7
Cov
18%
get_single_long_nick
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 43.8
« Webqq/Client/Method/_login2.pm ↑ Summary Webqq/Client/Method/_send_discuss_message.pm »
1 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 0 ▶sub Webqq::Client::get_single_long_nick{
Subroutine get_single_long_nick: not called CC=7 SCAR=40.3
Pod documented
4 0 my $self = shift;
5 0 my $uin = shift;
6
7 0 my $cache_data = $self->{cache_for_single_long_nick}->retrieve($uin);
8 0 ▶ return $cache_data if defined $cache_data;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cache_data 0 0 0
9  
10 0 my $api_url = 'http://s.web2.qq.com/api/get_single_long_nick2';
11 0 my $ua = $self->{ua};
12 0 ▶ my @headers = $self->{type} eq 'webqq'?(Referer=>'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=3')
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'} eq 'webqq' ? : 0 0 0
13 : (Referer=>'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1')
14 ;
15 my @query_string = (
16 tuin => $uin,
17 vfwebqq => $self->{qq_param}{vfwebqq},
18 0 t => time,
19 );
20 0 my @query_string_pairs;
21 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
22 0 my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers);
23 0 ▶ if($response->is_success){
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success) { } 0 0 0
24 0 ▶ print $response->content(),"\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
25 0 my $json = JSON->new->utf8->decode( $response->content() );
26 0 ▶ return undef if $json->{retcode} !=0;
Branch: 1 branch
BranchTrueFalseTotal
if $json->{"retcode"} != 0 0 0 0
27 #{"retcode":0,"result":[{"uin":308165330,"lnick":""}]}
28 0 my $single_long_nick = encode("utf8",$json->{result}[0]{lnick});
29 0 $self->{cache_for_single_long_nick}->store($uin,$single_long_nick);
30 0 return $single_long_nick;
31 }
32 0 else{return undef}
33 }
34 1 1;
« Webqq/Client/Method/_login2.pm ↑ Summary Webqq/Client/Method/_send_discuss_message.pm »