| 1 | 1 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use Webqq::Client::Util qw(console); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 0 | ▶ | sub Webqq::Client::get_qq_from_uin{ | ||||||||
|
Subroutine
get_qq_from_uin: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||
| 4 | 0 | my $self = shift; | |||||||||
| 5 | 0 | my $uin = shift; | |||||||||
| 6 | 0 | my $cache_data = $self->{cache_for_uin_to_qq}->retrieve($uin); | |||||||||
| 7 | 0 | ▶ | return $cache_data if defined $cache_data; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 8 | 0 | my $ua = $self->{ua}; | |||||||||
| 9 | 0 | my $api_url = 'http://s.web2.qq.com/api/get_friend_uin2'; | |||||||||
| 10 | 0 | ▶ | my @headers = $self->{type} eq 'webqq'? (Referer=>'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=3') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 11 | : (Referer=>'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1') | ||||||||||
| 12 | ; | ||||||||||
| 13 | my @query_string = ( | ||||||||||
| 14 | tuin => $uin, | ||||||||||
| 15 | type => 1, | ||||||||||
| 16 | vfwebqq => $self->{qq_param}{vfwebqq}, | ||||||||||
| 17 | 0 | t => time, | |||||||||
| 18 | ); | ||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | if($self->{type} eq 'webqq'){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | @query_string=( | ||||||||||
| 22 | tuin => $uin, | ||||||||||
| 23 | verifysession => undef, | ||||||||||
| 24 | type => 1, | ||||||||||
| 25 | code => undef, | ||||||||||
| 26 | vfwebqq => $self->{qq_param}{vfwebqq}, | ||||||||||
| 27 | 0 | t => time, | |||||||||
| 28 | ) | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 0 | my @query_string_pairs; | |||||||||
| 32 | 0 | ▶ | push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers); | |||||||||
| 34 | 0 | ▶ | if($response->is_success){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | ▶ | print $response->content(),"\n" if $self->{debug}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | my $json = JSON->new->utf8->decode( $response->content() ); | |||||||||
| 37 | 0 | ▶ | if($json->{retcode} !=0){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | console "从指定uin: $uin 查询QQ号码失败\n"; | |||||||||
| 39 | 0 | return undef; | |||||||||
| 40 | } | ||||||||||
| 41 | 0 | $self->{cache_for_uin_to_qq}->store($uin,$json->{result}{account}); | |||||||||
| 42 | 0 | $self->{cache_for_qq_to_uin}->store($json->{result}{account},$uin); | |||||||||
| 43 | 0 | return $json->{result}{account}; | |||||||||
| 44 | } | ||||||||||
| 45 | } | ||||||||||
| 46 | 1 | 1; | |||||||||