File Coverage

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


line stmt bran cond sub pod time code
1 1     1   5 use JSON;
  1         1  
  1         6  
2 1     1   143 use Webqq::Client::Util qw(console);
  1         1  
  1         219  
3             sub Webqq::Client::_get_vfwebqq {
4 0     0     my $self = shift;
5 0 0         return 1 if $self->{type} ne 'smartqq';
6 0           console "获取vfwebqq值...\n";
7 0           my $api_url = 'http://s.web2.qq.com/api/getvfwebqq';
8 0           my @query_string = (
9             ptwebqq => $self->{qq_param}{ptwebqq},
10             clientid => $self->{qq_param}{clientid},
11             psessionid => undef,
12             t => rand(),
13             );
14 0           my @headers = (
15             Referer => 'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1',
16             );
17 0           my @query_string_pairs;
18 0           push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string);
19            
20 0           my $ua = $self->{ua};
21 0           my $response = $ua->get($api_url . '?' .join("&",@query_string_pairs),@headers);
22 0 0         if($response->is_success){
23 0 0         print $response->content,"\n" if $self->{debug};
24 0           my $json = JSON->new->utf8->decode($response->content);
25 0 0         if($json->{retcode}!=0){
26 0           console "获取vfwebqq值失败...\n";
27 0           return 0;
28             }
29 0           $self->{qq_param}{vfwebqq} = $json->{result}{vfwebqq};
30 0           return $json->{result}{vfwebqq};
31             }
32             else{
33 0           console "获取vfwebqq值失败...\n";
34 0           return 0;
35             }
36             }
37             1;