| 1 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 0 | ▶ | sub Mojo::Webqq::Model::_get_user_info{ | ||||||||
|
Subroutine
_get_user_info: not called CC=3 SCAR=24.8
| |||||||||||
| 3 | 0 | my $self = shift; | |||||||||
| 4 | 0 | my $callback = shift; | |||||||||
| 5 | 0 | my $api_url ='https://s.web2.qq.com/api/get_self_info2'; | |||||||||
| 6 | 0 | my $headers = { | |||||||||
| 7 | Referer => 'https://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1', | ||||||||||
| 8 | json => 1, | ||||||||||
| 9 | ua_request_timeout => $self->model_update_timeout, | ||||||||||
| 10 | ua_retry_times => 3, | ||||||||||
| 11 | }; | ||||||||||
| 12 | 0 | my @query_string = ( | |||||||||
| 13 | t => time, | ||||||||||
| 14 | ); | ||||||||||
| 15 | 0 | ▶ | my $is_blocking = ref $callback eq "CODE"?0:1; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 0 | ▶ | my $handle = sub{ | ||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||
| 17 | 0 | my $json = shift; | |||||||||
| 18 | 0 | ▶ | return undef unless defined $json; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 0 | ▶ | return undef if $json->{retcode} !=0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | my $user = $json->{result}; | |||||||||
| 21 | 0 | $user->{state} = $self->mode; | |||||||||
| 22 | 0 | $user->{name} = delete $user->{nick}; | |||||||||
| 23 | 0 | $user->{client_type} = 'web'; | |||||||||
| 24 | 0 | $user->{birthday} = join( "-", @{ $user->{birthday} }{qw(year month day)} ); | |||||||||
| 25 | 0 | $user->{signature} = delete $user->{lnick}; | |||||||||
| 26 | 0 | $user->{sex} = delete $user->{gender}; | |||||||||
| 27 | #my $single_long_nick = $self->get_single_long_nick( $self->uid ); | ||||||||||
| 28 | #$json->{result}{signature} = $single_long_nick if defined $single_long_nick; | ||||||||||
| 29 | 0 | $user->{uid} = $self->uid; | |||||||||
| 30 | 0 | $user->{id} = delete $user->{uin}; | |||||||||
| 31 | 0 | return $user; | |||||||||
| 32 | 0 | }; | |||||||||
| 33 | 0 | ▶ | if($is_blocking){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | return $handle->( $self->http_get($self->gen_url($api_url,@query_string),$headers,) ); | |||||||||
| 35 | } | ||||||||||
| 36 | else{ | ||||||||||
| 37 | 0 | ▶ | $self->http_get($self->gen_url($api_url,@query_string),$headers,sub{ | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 38 | 0 | my $json = shift; | |||||||||
| 39 | 0 | $callback->( $handle->($json) ); | |||||||||
| 40 | 0 | }); | |||||||||
| 41 | } | ||||||||||
| 42 | } | ||||||||||
| 43 | 1 | 1; | |||||||||