| 1 | 1 | ▶ | use JSON; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | 1 | ▶ | use Webqq::Client::Util qw(code2state); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 0 | ▶ | sub Webqq::Client::_get_friend_info{ | ||||||||||||
|
Subroutine
_get_friend_info: not called CC=10 SCAR=47.0
| |||||||||||||||
| 4 | 0 | my $self = shift; | |||||||||||||
| 5 | 0 | my $uin = shift; | |||||||||||||
| 6 | 0 | my $api_url = 'http://s.web2.qq.com/api/get_friend_info2'; | |||||||||||||
| 7 | 0 | my $ua = $self->{ua}; | |||||||||||||
| 8 | 0 | ▶ | my @headers = $self->{type} eq 'webqq'? (Referer=>'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=3') | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 9 | : (Referer=>'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1') | ||||||||||||||
| 10 | ; | ||||||||||||||
| 11 | my @query_string = ( | ||||||||||||||
| 12 | tuin => $uin, | ||||||||||||||
| 13 | vfwebqq => $self->{qq_param}{vfwebqq}, | ||||||||||||||
| 14 | clientid => $self->{qq_param}{clientid}, | ||||||||||||||
| 15 | psessionid => $self->{qq_param}{psessionid}, | ||||||||||||||
| 16 | 0 | t => time, | |||||||||||||
| 17 | ); | ||||||||||||||
| 18 | |||||||||||||||
| 19 | 0 | ▶ | if($self->{type} eq 'webqq'){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 20 | @query_string = ( | ||||||||||||||
| 21 | tuin => $uin, | ||||||||||||||
| 22 | verifysession => undef, | ||||||||||||||
| 23 | code => undef, | ||||||||||||||
| 24 | vfwebqq => $self->{qq_param}{vfwebqq}, | ||||||||||||||
| 25 | 0 | t => time, | |||||||||||||
| 26 | ); | ||||||||||||||
| 27 | } | ||||||||||||||
| 28 | 0 | my @query_string_pairs; | |||||||||||||
| 29 | 0 | ▶ | push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 30 | 0 | my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers); | |||||||||||||
| 31 | 0 | ▶ | if($response->is_success){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 32 | 0 | ▶ | print $response->content(),"\n" if $self->{debug}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 33 | 0 | my $json = JSON->new->utf8->decode( $response->content() ); | |||||||||||||
| 34 | 0 | ▶ | return undef if $json->{retcode} !=0; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 35 | 0 | my $user_info = $json->{result}; | |||||||||||||
| 36 | 0 | for my $key (keys %{ $user_info }){ | |||||||||||||
| 37 | 0 | ▶ | if($key eq 'birthday'){ | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 38 | $user_info->{$key} = | ||||||||||||||
| 39 | 0 | encode("utf8", join("-",@{ $user_info->{birthday}}{qw(year month day)} ) ); | |||||||||||||
| 40 | } | ||||||||||||||
| 41 | elsif($key eq 'stat'){ | ||||||||||||||
| 42 | 0 | $user_info{state} = code2state($user_info->{'stat'}); | |||||||||||||
| 43 | } | ||||||||||||||
| 44 | else{ | ||||||||||||||
| 45 | 0 | $user_info->{$key} = encode("utf8",$user_info->{$key}); | |||||||||||||
| 46 | } | ||||||||||||||
| 47 | } | ||||||||||||||
| 48 | 0 | delete $user_info->{'stat'}; | |||||||||||||
| 49 | 0 | return $user_info; | |||||||||||||
| 50 | } | ||||||||||||||
| 51 | 0 | else{return undef} | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | 1 | 1; | |||||||||||||