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;
sub Webqq::Client::_get_group_sig {
my $self = shift;
my($id,$to_uin,$service_type,) = @_;
my $cache_data = $self->{cache_for_group_sig}->retrieve("$id|$to_uin|$service_type");
nt() if $self->{debug};
my $json = JSON->new->utf8->decode($response->content());
return undef if $json->{retcode}!=0;
return undef if $json->{result}{value} eq "";
$s
elf->{cache_for_group_sig}->store("$id|$to_uin|$service_type",$json->{result}{value},300);
return $json->{result}{value} ;
}
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;
sub Webqq::Client::_get_recent_info {
my $self = shift;
my $ua = $self->{ua};
return undef if $self->{type} ne 'smartqq';
my $api_url = 'http://d.web2.qq.com/channel/get_re
a->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($
());
return undef if $json->{retcode}!=0 ;
my %type = (0 => 'friend',1 => 'group', 2 => 'discuss');
my @recent;
for(@{$json->{result}}){
next unless
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::_relink{
my $self = shift;
$self->{login_state} = 'relink';
console "正在进行重新连接...\n";
my $ua = $self->{
for(my $i=0;$i<=$self->{ua_retry_times};$i++){
my $response = $ua->post($api_url,[r=>JSON->new->utf8->encode(\%r)], @headers);
if($response->is_success){
print $respon
ntent() if $self->{debug};
my $content = $response->content();
my $data = JSON->new->utf8->decode($content);
if($data->{retcode} ==0){
$self->{qq_pa
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(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;
sub Webqq::Client::_recv_message{
my $self = shift;
return if $self->{is_stop};
my $ua = $self->{asyn_ua};
my $api_url = ($self->{qq_param}{is_https}?'https':'http') . '://d.
$r{key} = 0;
$r{ids} = [];
}
my $post_content = [
r => JSON->new->utf8->encode(\%r),
];
if($self->{type} eq 'webqq'){
push @$post_content,(
use JSON;
sub Webqq::Client::_get_group_list_info{
my $self = shift;
my $ua = $self->{ua};
my $api_url = 'http://s.web2.qq.com/api/get_group_name_list_mask2';
my @headers = $self->{ty
webqq => $self->{qq_param}{vfwebqq},
);
my $post_content = [
r => JSON->new->encode(\%r),
];
#if($self->{debug}){
# require URI;
# my $uri = URI
f $self->{debug};
my $json = JSON->new->utf8->decode( $response->content() );
return undef unless exists $json->{result}{gnamelist};
return $json->{result};
}
else{ret
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:
use JSON;
use Encode;
use Storable qw(dclone);
sub Webqq::Client::_send_discuss_message {
my $self = shift;
return if $self->{type} ne 'smartqq';
my $msg = shift;
my $ua = $self->{asyn
>{to_uin},
face => $self->{qq_database}{user}{face} || 591,
content => JSON->new->utf8->encode($content),
msg_id => $msg->{msg_id},
clientid => $self
);
$s{content} = decode("utf8",$s{content});
my $post_content = [
r => JSON->new->utf8->encode(\%s),
];
if($self->{debug}){
require URI;
my $uri
use JSON;
use Webqq::Client::Util qw(console code2state code2client);
sub Webqq::Client::_get_group_info {
my $self = shift;
my $gcode = shift;
my $ua = $self->{ua};
my $api_url = 'htt
my $json;
eval{
$json = JSON->new->utf8->decode($response->content()) ;
};
$json = {} unless defined $json;
my $ginfo_status = exists $json->{result}
{ginfo}?"[ginfo-ok]":"[ginfo-not-ok]";
my $minfo_status = exists $json->{result}{minfo}?"[minfo-ok]":"[minfo-not-ok]";
if($self->{debug}){
print substr($response->
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(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;
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;
sub Webqq::Client::_get_stranger_info {
my $self = shift;
my $tuin = shift;
return undef if $self->{type} ne 'webqq';
my $ua = $self->{ua};
my $cache_data = $
lf->{debug};
my $json = JSON->new->utf8->decode($response->content());
return undef if $json->{retcode}!=0;
$json->{result}{nick} = encode("utf8",$json->{result}{nick});
$self->{cache_for_stranger}->store($tuin,$json->{result},300);
return $json->{result};
}
else{return undef}
}
1;
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,(
package Webqq::Message;
use Webqq::Message::Face;
use JSON;
use Encode;
use Webqq::Client::Util qw(console code2client);
use Scalar::Util qw(blessed);
sub reply_message{
my $client = shift;
my
= shift;
my ($json_txt) = @_;
my $json = undef;
eval{$json = JSON->new->utf8->decode($json_txt)};
console "解析消息失败: $@ 对应的消息内容为: $json_txt\n" if $@ and
$client->{debug};
if(ref $json eq 'HASH' and $json->{retcode}==0){
return {is_success=>1,status=>"发送成功"};
}
else{
return {is_success=>0,status=>"发送失败"};