| 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 | 1 | ▶ | use Webqq::Client::Util qw(code2client); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 0 | ▶ | sub Webqq::Client::_get_discuss_info { | ||||||||||||||||||||||||||
|
Subroutine
_get_discuss_info: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||
| 5 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 6 | 0 | my $ua = $self->{ua}; | |||||||||||||||||||||||||||
| 7 | 0 | my $did = shift; | |||||||||||||||||||||||||||
| 8 | 0 | ▶ | return undef if $self->{type} ne 'smartqq'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 9 | 0 | my $api_url = 'http://d.web2.qq.com/channel/get_discu_info'; | |||||||||||||||||||||||||||
| 10 | my @query_string = ( | ||||||||||||||||||||||||||||
| 11 | did => $did, | ||||||||||||||||||||||||||||
| 12 | vfwebqq => $self->{qq_param}{vfwebqq}, | ||||||||||||||||||||||||||||
| 13 | clientid => $self->{qq_param}{clientid}, | ||||||||||||||||||||||||||||
| 14 | psessionid => $self->{qq_param}{psessionid}, | ||||||||||||||||||||||||||||
| 15 | 0 | t => time(), | |||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | 0 | my @headers = ( | |||||||||||||||||||||||||||
| 18 | Referer => 'http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2', | ||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | my @query_string_pairs; | |||||||||||||||||||||||||||
| 22 | 0 | ▶ | push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 0 | my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | if($response->is_success){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | print $response->content,"\n" if $self->{debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | my $json; | |||||||||||||||||||||||||||
| 28 | 0 | eval{ | |||||||||||||||||||||||||||
| 29 | #my $d = $response->content(); | ||||||||||||||||||||||||||||
| 30 | #$d=~s/\\u([a-zA-Z0-9]{4})/encode("utf8",eval qq#"\\x{$1}"#)/eg; | ||||||||||||||||||||||||||||
| 31 | #print $d,"\n" if $self->{debug}; | ||||||||||||||||||||||||||||
| 32 | 0 | $json = JSON->new->utf8->decode($response->content()); | |||||||||||||||||||||||||||
| 33 | }; | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | print $@ if $@ and $self->{debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ and $self->{"debug"}
MC/DC0%0/2
$@ and $self->{"debug"}
$@
$self->{"debug"}
Truth table0%0/3
A and B
A= $@B= $self->{"debug"}
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $json = {} unless defined $json; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return undef if $json->{retcode}!=0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return undef unless exists $json->{result}{info}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | my %mem_list; | |||||||||||||||||||||||||||
| 40 | my %mem_status; | ||||||||||||||||||||||||||||
| 41 | 0 | my %mem_info; | |||||||||||||||||||||||||||
| 42 | 0 | my $minfo = []; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | for(@{ $json->{result}{info}{mem_list} }){ | |||||||||||||||||||||||||||
| 45 | 0 | $mem_list{$_->{mem_uin}}{ruin} = $_->{ruin}; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | for(@{ $json->{result}{mem_status} }){ | |||||||||||||||||||||||||||
| 49 | 0 | $mem_status{$_->{uin}}{status} = $_->{status}; | |||||||||||||||||||||||||||
| 50 | 0 | $mem_status{$_->{uin}}{client_type} = $_->{client_type}; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | for(@{ $json->{result}{mem_info} }){ | |||||||||||||||||||||||||||
| 54 | 0 | $mem_info{$_->{uin}}{nick} = encode("utf8",$_->{nick}); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | for(keys %mem_list){ | |||||||||||||||||||||||||||
| 58 | my $m = { | ||||||||||||||||||||||||||||
| 59 | uin => $_, | ||||||||||||||||||||||||||||
| 60 | nick => $mem_info{$_}{nick}, | ||||||||||||||||||||||||||||
| 61 | ruin => $mem_list{$_}{ruin}, | ||||||||||||||||||||||||||||
| 62 | 0 | }; | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | if(exists $mem_status{$_}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | $m->{state} = $mem_status{$_}{status}; | |||||||||||||||||||||||||||
| 65 | 0 | $m->{client_type} = code2client($mem_status{$_}{client_type}); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | else{ | ||||||||||||||||||||||||||||
| 68 | 0 | $m->{state} = 'offline'; | |||||||||||||||||||||||||||
| 69 | 0 | $m->{client_type} = 'unknown'; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 0 | push @{$minfo},$m; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | my $discuss_info = { | ||||||||||||||||||||||||||||
| 75 | dinfo => { | ||||||||||||||||||||||||||||
| 76 | did => $json->{result}{info}{did}, | ||||||||||||||||||||||||||||
| 77 | owner => $json->{result}{info}{discu_owner}, | ||||||||||||||||||||||||||||
| 78 | name => encode("utf8",$json->{result}{info}{discu_name}), | ||||||||||||||||||||||||||||
| 79 | info_seq => $json->{result}{info}{info_seq}, | ||||||||||||||||||||||||||||
| 80 | }, | ||||||||||||||||||||||||||||
| 81 | 0 | ▶ | minfo => (@$minfo>0?$minfo:undef), | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | } ; | ||||||||||||||||||||||||||||
| 83 | 0 | return $discuss_info; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | 0 | else{return undef;} | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | 1 | 1; | |||||||||||||||||||||||||||