File Coverage

blib/lib/Webqq/Client/Method/_get_group_list_info.pm
Criterion Covered Total %
statement 3 16 18.7
branch 0 8 0.0
condition n/a
subroutine 1 2 50.0
pod n/a
total 4 26 15.3


line stmt bran cond sub pod time code
1 1     1   4 use JSON;
  1         1  
  1         4  
2             sub Webqq::Client::_get_group_list_info{
3 0     0     my $self = shift;
4 0           my $ua = $self->{ua};
5 0           my $api_url = 'http://s.web2.qq.com/api/get_group_name_list_mask2';
6 0 0         my @headers = $self->{type} eq 'webqq'? (Referer => 'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=3')
7             : (Referer => 'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1')
8             ;
9 0           my %r = (
10             hash => hash($self->{qq_param}{ptwebqq},$self->{qq_param}{qq}),
11             vfwebqq => $self->{qq_param}{vfwebqq},
12             );
13              
14 0           my $post_content = [
15             r => JSON->new->encode(\%r),
16             ];
17              
18             #if($self->{debug}){
19             # require URI;
20             # my $uri = URI->new('http:');
21             # $uri->query_form($post_content);
22             # print $api_url,"\n";
23             # print $uri->query(),"\n";
24             #}
25              
26 0           my $response = $ua->post(
27             $api_url,
28             $post_content,
29             @headers,
30             );
31 0 0         if($response->is_success){
  0            
32 0 0         print $response->content(),"\n" if $self->{debug};
33 0           my $json = JSON->new->utf8->decode( $response->content() );
34 0 0         return undef unless exists $json->{result}{gnamelist};
35 0           return $json->{result};
36             }
37             else{return undef}
38             }
39             1;