| 1 | 1 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use Webqq::Client::Util qw(code2state code2client); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 0 | ▶ | sub Webqq::Client::_get_friends_state { | ||||||||
|
Subroutine
_get_friends_state: not called CC=8 SCAR=42.8
| |||||||||||
| 4 | 0 | my $self = shift; | |||||||||
| 5 | 0 | ▶ | return undef if $self->{type} ne 'smartqq'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 6 | 0 | my $ua = $self->{ua}; | |||||||||
| 7 | 0 | my $api_url = 'http://d.web2.qq.com/channel/get_online_buddies2'; | |||||||||
| 8 | 0 | my @headers = ( | |||||||||
| 9 | Referer=>'http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2' | ||||||||||
| 10 | ); | ||||||||||
| 11 | my @query_string = ( | ||||||||||
| 12 | vfwebqq => $self->{qq_param}{vfwebqq}, | ||||||||||
| 13 | clientid => $self->{qq_param}{clientid}, | ||||||||||
| 14 | psessionid => $self->{qq_param}{psessionid}, | ||||||||||
| 15 | 0 | t => time, | |||||||||
| 16 | ); | ||||||||||
| 17 | 0 | my @query_string_pairs; | |||||||||
| 18 | 0 | ▶ | push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 0 | ▶ | print "GET $api_url\n" if $self->{debug}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers); | |||||||||
| 21 | 0 | ▶ | if($response->is_success){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 0 | ▶ | print $response->content(),"\n" if $self->{debug}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | my $json = JSON->new->utf8->decode( $response->content() ); | |||||||||
| 24 | 0 | ▶ | return undef if $json->{retcode} !=0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | for(@{$json->{result}}){ | |||||||||
| 26 | 0 | $_->{client_type} = code2client($_->{client_type}); | |||||||||
| 27 | 0 | $_->{state} = $_->{status}; | |||||||||
| 28 | 0 | delete $_->{status}; | |||||||||
| 29 | } | ||||||||||
| 30 | 0 | return $json->{result}; | |||||||||
| 31 | } | ||||||||||
| 32 | 0 | else{return undef} | |||||||||
| 33 | } | ||||||||||
| 34 | 1 | 1; | |||||||||