File Coverage

blib/lib/Webqq/Client/Method/_get_user_info.pm
Criterion Covered Total %
statement 6 26 23.0
branch 0 12 0.0
condition n/a
subroutine 2 3 66.6
pod n/a
total 8 41 19.5


line stmt bran cond sub pod time code
1 1     1   4 use JSON;
  1         1  
  1         5  
2 1     1   124 use Webqq::Client::Util qw(code2state code2client);
  1         2  
  1         497  
3             sub Webqq::Client::_get_user_info{
4 0     0     my $self = shift;
5 0           my $webqq_api_url ='http://s.web2.qq.com/api/get_friend_info2';
6 0           my $smartqq_api_url ='http://s.web2.qq.com/api/get_self_info2';
7 0 0         my $api_url = $self->{type} eq 'webqq'? $webqq_api_url
8             : $smartqq_api_url
9             ;
10 0           my $ua = $self->{ua};
11 0 0         my @headers = $self->{type} eq 'webqq'? (Referer=>'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=3')
12             : (Referer=>'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1');
13             ;
14            
15 0           my @query_string = (
16             t => time,
17             );
18 0 0         if($self->{type} eq 'webqq'){
19 0           unshift @query_string,(
20             tuin => $self->{qq_param}{qq},
21             verifysession => undef,
22             code => undef,
23             vfwebqq => $self->{qq_param}{vfwebqq},
24             vfwebqq => $self->{qq_param}{vfwebqq}
25             );
26             }
27 0           my @query_string_pairs;
28 0           push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string);
29 0           my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers);
30 0 0         if($response->is_success){
  0            
31 0 0         print $response->content(),"\n" if $self->{debug};
32 0           my $json = JSON->new->utf8->decode( $response->content() );
33 0 0         return undef if $json->{retcode} !=0;
34 0           $json->{result}{state} = $self->{qq_param}{state};
35 0           $json->{result}{client_type} = 'web';
36 0           return $json->{result};
37             }
38             else{return undef}
39             }
40             1;