File Coverage

blib/lib/Webqq/Client/Method/_get_friends_state.pm
Criterion Covered Total %
statement 6 27 22.2
branch 0 10 0.0
condition n/a
subroutine 2 3 66.6
pod n/a
total 8 40 20.0


line stmt bran cond sub pod time code
1 1     1   3 use JSON;
  1         2  
  1         5  
2 1     1   81 use Webqq::Client::Util qw(code2state code2client);
  1         3  
  1         406  
3             sub Webqq::Client::_get_friends_state {
4 0     0     my $self = shift;
5 0 0         return undef if $self->{type} ne 'smartqq';
6 0           my $ua = $self->{ua};
7 0           my $api_url = 'http://d.web2.qq.com/channel/get_online_buddies2';
8 0           my @headers = (
9             Referer=>'http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2'
10             );
11 0           my @query_string = (
12             vfwebqq => $self->{qq_param}{vfwebqq},
13             clientid => $self->{qq_param}{clientid},
14             psessionid => $self->{qq_param}{psessionid},
15             t => time,
16             );
17 0           my @query_string_pairs;
18 0           push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string);
19 0 0         print "GET $api_url\n" if $self->{debug};
20 0           my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers);
21 0 0         if($response->is_success){
  0            
22 0 0         print $response->content(),"\n" if $self->{debug};
23 0           my $json = JSON->new->utf8->decode( $response->content() );
24 0 0         return undef if $json->{retcode} !=0;
25 0           for(@{$json->{result}}){
  0            
26 0           $_->{client_type} = code2client($_->{client_type});
27 0           $_->{state} = $_->{status};
28 0           delete $_->{status};
29             }
30 0           return $json->{result};
31             }
32             else{return undef}
33             }
34             1;