| 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 | 0 | ▶ | sub Webqq::Client::_get_stranger_info { | ||||||||
|
Subroutine
_get_stranger_info: not called CC=7 SCAR=40.3
| |||||||||||
| 4 | 0 | my $self = shift; | |||||||||
| 5 | 0 | my $tuin = shift; | |||||||||
| 6 | 0 | ▶ | return undef if $self->{type} ne 'webqq'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 7 | 0 | my $ua = $self->{ua}; | |||||||||
| 8 | 0 | my $cache_data = $self->{cache_for_stranger}->retrieve($tuin); | |||||||||
| 9 | 0 | ▶ | return $cache_data if defined $cache_data; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 10 | 0 | my $api_url = 'http://s.web2.qq.com/api/get_stranger_info2'; | |||||||||
| 11 | 0 | my @headers = ( | |||||||||
| 12 | Referer => 'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=3', | ||||||||||
| 13 | 'Content-Type'=>'utf-8', | ||||||||||
| 14 | ); | ||||||||||
| 15 | my @query_string = ( | ||||||||||
| 16 | tuin => $tuin, | ||||||||||
| 17 | verifysession => undef, | ||||||||||
| 18 | gid => 0, | ||||||||||
| 19 | code => undef, | ||||||||||
| 20 | vfwebqq => $self->{qq_param}{vfwebqq}, | ||||||||||
| 21 | 0 | t => time, | |||||||||
| 22 | ); | ||||||||||
| 23 | |||||||||||
| 24 | 0 | my @query_string_pairs; | |||||||||
| 25 | 0 | ▶ | push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers); | |||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | if($response->is_success){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 0 | ▶ | print $response->content(),"\n" if $self->{debug}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 0 | my $json = JSON->new->utf8->decode($response->content()); | |||||||||
| 31 | 0 | ▶ | return undef if $json->{retcode}!=0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 0 | $json->{result}{nick} = encode("utf8",$json->{result}{nick}); | |||||||||
| 33 | 0 | $self->{cache_for_stranger}->store($tuin,$json->{result},300); | |||||||||
| 34 | 0 | return $json->{result}; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | else{return undef} | |||||||||
| 38 | } | ||||||||||
| 39 | 1 | 1; | |||||||||