my $json = $self->http_post($self->gen_url2($api,@query_string),{Referer=>'https://'.$self->domain . '/',json=>1},json=>$post);
next unless defined $json;
next if $json->{BaseRes
ponse}{Ret}!=0;
for my $e (@{$json->{ContactList}}){
my $member = {};
for(keys %KEY_MAP_GROUP_MEMBER){
$member->{$_} = $e->{$KEY_MAP_GROUP_MEMBER{$_}} /
;
my $json = $self->http_post($self->gen_url($api,@query_string),{json=>1,Referer=>'https://' . $self->domain . '/'},json=>$post);
return if not defined $json;
return if $json->{BaseResp
};
my $json = $self->http_post($self->gen_url($api,@query_string),{json=>1,Referer=>'https://' . $self->domain . '/'},json=>$post);
return if not defined $json;
return if $json->{BaseResp
_parse_sync_data {
my $self = shift;
my $json = shift;
return if not defined $json;
my @logout_code = qw(1100 1102 1205);
if($json->{BaseResponse}{Ret} == 1101){#手机端强制
$self->logout($json->{BaseResponse}{Ret});
$self->stop();
}
elsif(first {$json->{BaseResponse}{Ret} == $_} @logout_code ){
$self->relogin($json->{BaseResponse}{Ret});
}
elsif($json->{BaseResponse}{Ret} !=0){
$self->warn("收到无法识别消息代码[$json->{BaseResponse}{Ret}],已将其忽略");
$self->emit(unknown_retcode=>$json->{BaseRespo
my $json = $self->http_post($self->gen_url($api,@query_string),{json=>1,Referer=>'https://'.$self->domain .'/'},json=>$post);
return if not defined $json;
return if $json->{BaseRespon
lf->sync_key($json->{SyncKey}) if $json->{SyncKey}{Count} !=0;
$self->skey($json->{Skey}) if $json->{Skey};
my $user = {};
for(keys %KEY_MAP_USER){
$user->{$_} = $json->{User}{$KEY
_MAP_USER{$_}} // "";
}
my @friends;
my @groups;
for my $e (@{ $json->{ContactList} }){
if($self->is_group_id($e->{UserName})){
my $group = {};
for(key
my $json = $self->http_post($self->gen_url2($api,@query_string),{Referer=>'https://'.$self->domain . '/',json=>1},json=>$post);
next unless defined $json;
next if $json->{BaseRes
ponse}{Ret}!=0;
for my $e (@{$json->{ContactList}}){
my $friend = {};
for(keys %KEY_MAP_FRIEND){
$friend->{$_} = $e->{$KEY_MAP_FRIEND{$_}} // "";
my $json = $self->http_post($self->gen_url2($api,@query_string),{Referer=>'https://'.$self->domain . '/',json=>1},json=>$post);
next unless defined $json;
next if $json->{BaseRes
ponse}{Ret}!=0;
for my $e (@{$json->{ContactList}}){
if($self->is_group_id($e->{UserName})){
my $group = {};
for(keys %KEY_MAP_GROUP){
parse_send_status_data {
my $self = shift;
my $json = shift;
if(defined $json){
if($json->{MsgID}){
my $id = $json->{MsgID} . ":" . ($self->type eq 'group_message'?$sel
$self->{id} = $id;
}
if($json->{BaseResponse}{Ret}!=0){
$self->send_status(
code=>$json->{BaseResponse}{Ret},
msg=
end_status(code=>-1,msg=>"发送失败",info=>"unknown data");
}
}
sub to_json_hash{
my $self = shift;
my $json = {};
for my $key ( ( (keys %$self),qw(sender receiver group ) ) ){
qw(blessed);
use List::Util qw(first);
sub client {
return $Mojo::Weixin::_CLIENT;
}
sub to_json_hash{
my $self = shift;
my $is_keep_member = shift || 1;
my $hash = {};
for(ke
eq "ARRAY"){
for my $m(@{$self->{member}}){
my $member_hash = $m->to_json_hash();
push @{$hash->{member}},$member_hash;
}
}
}
de($signtemp . $orignal,"");
my $json = $client->http_post("http://web.file.myqcloud.com/files/v1/$appid/$bucket/$name",
{ Authorization=>$sign, json=>1 ,ua_debug_req_body=>0},
fo
);
if(not defined $json){
$client->warn("二维码图片上传云存储失败: 响应数据异常");
return;
}
elsif(defined $json and $json->{code} != 0 ){
$c
lient->warn("二维码图片上传云存储失败: " . $json->{message});
return;
}
my $url = $json->{data}{source_url};
$url=~s/(^https?:\/\/)([^\/]+)(.*)/$1$mydomain$3/ if (
? "html"
: $mime=~/^text\/json/i ? "json"
: $mime=~/^application\/json/i ? "json"
: $mime=~/^video\/mp4/i
: $mime=~/^audio\/mpeg/i ? "mp3"
: $mime=~/^application\/json/i ? "json"
: "dat"
;
retur
的云存储路径,防止好像干扰
my $json = $client->http_post('https://sm.ms/api/upload',{json=>1},form=>{
format=>'json',
smfile=>{filename=>$qrcode_path,conte
if(not defined $json){
$client->warn("二维码图片上传云存储失败: 响应数据异常");
return;
}
elsif(defined $json and $json->{code} ne 'succes
存储失败: " . $json->{msg});
return;
}
$client->qrcode_upload_url($json->{data}{url});
$client->info("二维码已上传云存储[ ". $json->{data}{url} . " ]")
$json = {
"key" => $data->{apikey} || "bbdaba85b5cf47bc80e27cbaee7a77df",
"userid" => $msg->sender->id,
"info" => $input,
};
$json
pi,{json=>1},json=>$json,sub{
my $json = shift;
return unless defined $json;
return if $json->{code}=~/^4000[1-7]$/;
my $reply;
if($json->{c
return unless $json->{text};
$reply = $json->{text};
}
elsif($json->{code} == 200000){
$reply = "$json->{text}$json->{url}";
e,{json=>1},sub{
my $json = shift;
return unless defined $json;
my $doc;
my $code;
if(defined $json->{code} and $json->{
code} == 404){
$doc = "模块名称: $module ($json->{message})" ;
$code = 404;
$metacpan_cache->store($module,{code=>$code,doc=>$doc},6048
= 200;
my $author = $json->{author};
my $version = $json->{version};
my $abstract= $json->{abstract};
my $podlin
$senderType = '2';
}
return if !$title or !$message;
my $messageJson = '{"content":"{\"isAt\":\"'.$isAt.'\",\"type\":\"'.$type.'\",\"title\":\"'.$title.'\",\"message\
}"}';
print "appId=".$app_id."messageJson=".$messageJson."pushIds=".$registration_id.$api_key;
my $sign = md5_sum("appId=".$app_id."messageJson=".$messageJson."pushIds=".$registration_id.$api_key)
=>1,ua_debug_res_body=>1,json=>1},
form=>{
appId => $app_id,
pushIds => $registration_id,
messageJson=>$messageJson,
sign => $sign,
$unicode_data);
my $json = $client->from_json($data);
if(defined $json and defined $json->{pins}){
for(@{ $json->{pins} }){
'application/json',
Referer=>$board->{url},
'X-Request'=>'JSON',
'X-Requested-With'=>'XMLHttpRequest',
json=>1,
my $json = shift;
return if not defined $json;
if(defined $json->{board}{pins} ){
if(@{$json->{board}{pins}} > 0){
my $json = $client->from_json($content);
if(not defined $json){
$client->debug("[ " . __PACKAGE__ . " ]json数据解析失败");
return;
}
my $result = join "\n",map {$_->{Title}} @{$json};
$result = $result;
$msg->reply($result);
my $delay =shift;
$client->http_get('http://apis.baidu.com/gushi/grid/p1',{json=>1,apikey=>$data->{apikey}||'20d7db97e337ffa35ae0838439c9db5d'},form=>{count=>1,fmt=>0},$delay->b
my $json = shift;
return if not defined $json;
return if $json->{status} != 0;
my $id = $json->{data}[0]{id} if ref $json->{data} eq
p2',{json=>1,apikey=>$data->{apikey}||'20d7db97e337ffa35ae0838439c9db5d'},form=>{id=>$id,fmt=>0},sub{
my $json = shift;
return if not defined $json;
my $json = $self->http_post($self->gen_url($api,@query_string),{blocking=>1,Referer=>'https://' . $self->domain . '/',json=>1},json=>$post);
return if not defined $json;
return if $json->{Ba
g/bot' . $data->{api_key} .'/sendPhoto';
my $response = $client->http_post($telegram_api,{json=>1},form=>{
chat_id => $data->{chat_id},
caption => '微信登录二维