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;
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;
}
}
}
: $mime=~/^text\/json/i ? "json"
: $mime=~/^application\/json/i ? "json"
: $mime=~/^v
^audio\/mpeg/i ? "mp3"
: $mime=~/^application\/json/i ? "json"
: "dat"
_post(
'https://file.' . $self->domain .'/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json',
{ json=>1,
Referer=>'https://' . $self->domain . '/',
ua_request_timeo
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}}){
next if not $self->is_group_id($e->{UserName});
my $group = {};
for(keys %KEY_MAP_GROUP){
};
my $json = $self->http_post($self->gen_url($api,@query_string),{json=>1,Referer=>'https://' . $self->domain . '/'},json=>$post);
if(not defined $json or (defined $json and $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->{Base
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->{Base
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->{Base
et;
my $json = $self->http_get($self->gen_url($api,@query_string),{Referer=>'https://'.$self->domain . '/',json=>1});
#return [\@friends,\@groups] if not defined $json;
return
not defined $json;
return if $json->{BaseResponse}{Ret}!=0;
return if $json->{MemberCount} == 0;
if ($self->is_update_all_friend and defined $json->{Seq} and $json->{Seq} != 0)
部分
$flag = 1 ;
$seq = $json->{Seq};
}
else{
$flag = 0;
}
for my $e ( @{ $json->{MemberList} } ){
if($self->is_group_
media msg");
return;
}
my $callback = sub{
my $json = shift;
$msg->_parse_send_status_data($json);
if(!$msg->is_success and $msg->ttl > 0){
$self->
my $api;
my @query_string = (
fun => 'async',
f => 'json',
$self->pass_ticket?(pass_ticket => $self->url_escape($self->pass_ticket)):()
my $json = $self->to_json($post);
$json =~ s#__SLASH__#/#g;
$self->http_post(
$self->gen_url($api,@query_string),
{json=>1,Referer=>'
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{$_}} // "";
? "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
=> 1,
},
};
my $callback = sub {
my $json = shift;
$msg->_parse_send_status_data($json);
if(!$msg->is_success and $msg->ttl > 0){
$self->
);
}
$self->emit(send_message => $msg);
}
};
#Mojo::JSON::to_json will escape the slash charactor '/' into '\/'
#Weixin Server doesn't supported this fea
my $json = $self->to_json($post);
$json =~ s#__SLASH__#/#g;
# dirty work done
$self->http_post($self->gen_url($api,@query_string),{json=>1,'Content-Type'=>'application/json'},$json,$cal
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}}){
if($self->is_group_id($e->{UserName})){
my $group = {};
for(keys %KEY_MAP_GROUP){
_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
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 ) ) ){
;
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 $callback = sub{
my ($json,$ua,$tx) = @_;
my $status = 1;
if(not defined $json){$status = 0;}
elsif(defined $json and $json->{BaseResponse}{Ret} == -1){$status
->res->body,$json);
$self->emit("sync_over",$json,$status);
};
$self->http_post($self->gen_url($api,@query_string),{Referer=>'https://' . $self->domain . '/',json=>1},json=>$post,$cal
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
onse}{Ret}!=0;
my $group = {id=>$json->{ChatRoomName},name=>$json->{Topic},member=>[]};
for my $m (@{ $json->{MemberList} }){
my $member = {};
for(keys %Mojo::Weixin::Const::KE
};
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_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{$_}} /