|
sub Mojo::Webqq::Model::_get_user_friends_ext {
my $self = shift ;
my $callback = shift ;
my $is_blocking = ref $callback eq "CODE" ?0:1;
my $handle = sub {
my $json = shift ;
return if not defined $json ;
return if $json ->{ec}!=0;
my @result ;
for my $category_index ( keys %{ $json ->{result}}){
my $category = ( $category_index ==0 and ! defined $json ->{result}{ $category_index }{gname})? "我的好友" :( $json ->{result}{ $category_index }{gname});
next if ref $json ->{result}{ $category_index }{mems} ne "ARRAY" ;
for my $f (@{ $json ->{result}{ $category_index }{mems} }){
my $friend = {
category => $self ->xmlescape_parse( $category ),
displayname => $self ->xmlescape_parse( $f ->{name}),
uid => $f ->{uin},
} ;
push @result , $friend ;
}
}
return \ @result ;
};
if ( $is_blocking ){
}
else {
my $json = shift ;
$callback ->( $handle ->( $json ) );
});
}
}
1;
|