生一个监听本地指定端口的HTTP服务器,用于接收api请求
返回数据完全为JSON格式,接口包括:
获取个人信息 /openqq/get_user_info
获取好友信息
escape);
use JSON;
sub call{
my $self = shift;
my $client = $self->{client};
my $env = shift;
return [
200,
['Content-Type' => 'text/plain'],
[JSON->new->encod
r::Session::CHI>,
L<Cookie|Dancer::Session::Cookie>,
L<DBIC|Dancer::Session::DBIC>,
L<JSON|Dancer::Session::JSON>,
L<Memcached|Dancer::Session::Memcached>,
L<Memcached::Fast|Dancer::Session::Memcache
escape);
use JSON;
sub call{
my $self = shift;
my $client = $self->{client};
my $env = shift;
return [
200,
['Content-Type' => 'text/plain'],
[JSON->new->encod
:Openqq::SendGroupMessage;
use parent qw(Plack::Component);
use URI::Escape qw(uri_unescape);
use JSON;
use Encode;
sub call{
my $self = shift;
my $client = $self->{client};
my $env = shi
};
my $json = JSON->new->utf8->encode($res);
$responder->([
200,
['Content-Type' => 'text/plain'],
[$json],
]);
escape);
use JSON;
sub call{
my $self = shift;
my $client = $self->{client};
my $env = shift;
return [
200,
['Content-Type' => 'text/plain'],
[JSON->new->encod
escape);
use JSON;
sub call{
my $self = shift;
my $client = $self->{client};
my $env = shift;
return [
200,
['Content-Type' => 'text/plain'],
[JSON->new->encod
escape);
use JSON;
sub call{
my $self = shift;
my $client = $self->{client};
my $env = shift;
return [
200,
['Content-Type' => 'text/plain'],
[JSON->new->encod
::Openqq::SendSessMessage;
use parent qw(Plack::Component);
use URI::Escape qw(uri_unescape);
use JSON;
use Encode;;
sub call{
my $self = shift;
my $client = $self->{client};
my $env = sh
};
my $json = JSON->new->utf8->encode($res);
$responder->([
200,
['Content-Type' => 'text/plain'],
[$json],
]);
use JSON;
use Encode;
sub Webqq::Client::_get_discuss_list_info {
my $self = shift;
my $ua = $self->{ua};
return undef if $self->{type} ne 'smartqq';
my $api_url = 'http://s.web2.qq.co
my $json;
eval{
$json = JSON->new->utf8->decode($response->content()) ;
};
print $@ if $@ and $self->{debug};
$json = {} unless defined $json;
return undef if $json->{retcode}!=0;
for(@{ $json->{result}{dnamelist} }){
$_->{name} = encode("utf8",$_->{name});
}
return $json->{result}{dnamelist};
use JSON;
use Encode;
use Storable qw(dclone);
sub Webqq::Client::_send_group_message{
my($self,$msg) = @_;
#将整个hash从UTF8还原回uincode编码
my $ua = $self->{asyn_ua};
my $
$msg->{content}),[]];
my %s = (
group_uin => $msg->{to_uin},
content => JSON->new->utf8->encode($content),
msg_id => $msg->{msg_id},
clientid => $self
$self->{qq_database}{user}{face} || "591";
}
my $post_content = [
r => JSON->new->utf8->encode(\%s),
];
if($self->{type} eq 'webqq'){
push @$post_content,(
use JSON;
use Webqq::Client::Util qw(console);
sub Webqq::Client::get_qq_from_uin{
my $self = shift;
my $uin = shift;
my $cache_data = $self->{cache_for_uin_to_qq}->retrieve($uin);
re
print $response->content(),"\n" if $self->{debug};
my $json = JSON->new->utf8->decode( $response->content() );
if($json->{retcode} !=0){
console "从指定uin: $uin 查询
$self->{cache_for_uin_to_qq}->store($uin,$json->{result}{account});
$self->{cache_for_qq_to_uin}->store($json->{result}{account},$uin);
return $json->{result}{account};
}
}
1;
use JSON;
use Webqq::Client::Util qw(code2state code2client);
sub Webqq::Client::_get_user_info{
my $self = shift;
my $webqq_api_url ='http://s.web2.qq.com/api/get_friend_info2';
my $sma
my $json = JSON->new->utf8->decode( $response->content() );
return undef if $json->{retcode} !=0;
$json->{result}{state} = $self->{qq_param}{state};
$json->{result}{
client_type} = 'web';
return $json->{result};
}
else{return undef}
}
1;
生一个监听本地指定端口的HTTP服务器,用于接收api请求
返回数据完全为JSON格式,接口包括:
获取个人信息 /openqq/get_user_info
获取好友信息
use JSON;
use Encode;
use Storable qw(dclone);
sub Webqq::Client::_send_message{
my($self,$msg) = @_;
#将整个hash从UTF8还原为unicode
my $ua = $self->{asyn_ua};
my $callback = su
=> $msg->{to_uin},
face => $self->{qq_database}{user}{face} || 570,
content => JSON->new->utf8->encode($content),
msg_id => $msg->{msg_id},
clientid => $self->{qq_
$self->{qq_database}{user}{face} || "591";
}
my $post_content = [
r => JSON->new->utf8->encode(\%s),
];
if($self->{type} eq 'webqq'){
push @$post_content,(
use JSON;
use Encode;
sub Webqq::Client::get_single_long_nick{
my $self = shift;
my $uin = shift;
my $cache_data = $self->{cache_for_single_long_nick}->retrieve($uin);
return
response->content(),"\n" if $self->{debug};
my $json = JSON->new->utf8->decode( $response->content() );
return undef if $json->{retcode} !=0;
#{"retcode":0,"result":[{"uin"
:308165330,"lnick":""}]}
my $single_long_nick = encode("utf8",$json->{result}[0]{lnick});
$self->{cache_for_single_long_nick}->store($uin,$single_long_nick);
return $single_lon
use JSON;
use Webqq::Client::Util qw(console);
sub Webqq::Client::_get_vfwebqq {
my $self = shift;
return 1 if $self->{type} ne 'smartqq';
console "获取vfwebqq值...\n";
my $api_url
print $response->content,"\n" if $self->{debug};
my $json = JSON->new->utf8->decode($response->content);
if($json->{retcode}!=0){
console "获取vfwebqq值失败...\n"
;
return 0;
}
$self->{qq_param}{vfwebqq} = $json->{result}{vfwebqq};
return $json->{result}{vfwebqq};
}
else{
console "获取vfwebqq值失败...\
use JSON;
use Webqq::Client::Util qw(code2state code2client);
sub Webqq::Client::_get_friends_state {
my $self = shift;
return undef if $self->{type} ne 'smartqq';
my $ua = $self->{ua};
),"\n" if $self->{debug};
my $json = JSON->new->utf8->decode( $response->content() );
return undef if $json->{retcode} !=0;
for(@{$json->{result}}){
$_->{client
_type} = code2client($_->{client_type});
$_->{state} = $_->{status};
delete $_->{status};
}
return $json->{result};
}
else{return undef}
}
1;
use JSON;
use Webqq::Client::Util qw(hash);
sub Webqq::Client::_get_user_friends{
my $self = shift;
my $api_url = 'http://s.web2.qq.com/api/get_user_friends2';
my $ua = $self->{ua};
my
$ua->post($api_url,[r=>JSON->new->utf8->encode(\%r)],@headers);
if($response->is_success){
print $response->content(),"\n" if $self->{debug};
my $json = JSON->new->utf8->decode($re
sponse->content());
return undef if $json->{retcode}!=0 ;
my $friends_state = $self->_get_friends_state();
my %categories ;
my %info;
my %marknames;
my
use JSON;
use Webqq::Client::Util qw(console);
sub Webqq::Client::get_dwz {
my $self = shift;
my $url = shift;
my $api = 'http://dwz.cn/create.php';
my $ua = $self->{ua};
my $res;
alarm 0;
if($res->is_success){
my $json = JSON->new->utf8->decode($res->content);
$dwz = $json->{tinyurl} if $json->{status}==0;
};
};
console "[Webqq: