Webqq/Client/Method/get_qq_from_uin.pm

filter: Statementstmt 24.1% 7 / 29 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 21.2% 10 / 47 CC 8 SCAR 40.6
CC
8
Cov
16%
get_qq_from_uin
72.0
BEGIN
1.0
BEGIN
1.0
CRAP 57.8
« Webqq/Client/Method/_get_friends_state.pm ↑ Summary Webqq/Client/Plugin/CpanRecentModule.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::get_qq_from_uin{
Subroutine get_qq_from_uin: not called CC=8 SCAR=42.8
Pod documented
4 0 my $self = shift;
5 0 my $uin = shift;
6 0 my $cache_data = $self->{cache_for_uin_to_qq}->retrieve($uin);
7 0 ▶ return $cache_data if defined $cache_data;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cache_data 0 0 0
8 0 my $ua = $self->{ua};
9 0 my $api_url = 'http://s.web2.qq.com/api/get_friend_uin2';
10 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
11 : (Referer=>'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1')
12 ;
13 my @query_string = (
14 tuin => $uin,
15 type => 1,
16 vfwebqq => $self->{qq_param}{vfwebqq},
17 0 t => time,
18 );
19
20 0 ▶ if($self->{type} eq 'webqq'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "webqq") 0 0 0
21 @query_string=(
22 tuin => $uin,
23 verifysession => undef,
24 type => 1,
25 code => undef,
26 vfwebqq => $self->{qq_param}{vfwebqq},
27 0 t => time,
28 )
29 }
30  
31 0 my @query_string_pairs;
32 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
33 0 my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers);
34 0 ▶ if($response->is_success){
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success) 0 0 0
35 0 ▶ print $response->content(),"\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
36 0 my $json = JSON->new->utf8->decode( $response->content() );
37 0 ▶ if($json->{retcode} !=0){
Branch: 1 branch
BranchTrueFalseTotal
if ($json->{"retcode"} != 0) 0 0 0
38 0 console "从指定uin: $uin 查询QQ号码失败\n";
39 0 return undef;
40 }
41 0 $self->{cache_for_uin_to_qq}->store($uin,$json->{result}{account});
42 0 $self->{cache_for_qq_to_uin}->store($json->{result}{account},$uin);
43 0 return $json->{result}{account};
44 }
45 }
46 1 1;
« Webqq/Client/Method/_get_friends_state.pm ↑ Summary Webqq/Client/Plugin/CpanRecentModule.pm »