$json = {plugin => []};
for my $attr (@attr){
$json->{$attr} = $self->$attr;
}
$json->{previous_state} = $previous_state;
$json->{pid} = $$;
$json-
>{os} = $^O;
for my $p (keys %{ $self->plugins }){
push @{ $json->{plugin} } , { name=>$self->plugins->{$p}{name},priority=>$self->plugins->{$p}{priority},auto_call=>$self->plugin
,call_on_load=>$self->plugins->{$p}{call_on_load} } ;
}
$self->spurt($self->to_json($json),$self->state_path);
};
$self->warn("客户端状态信息保存失败:$@") if $@;
}
= {
Referer => 'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2',
json => 1,
};
my %r = (
vfwebqq => $self->vfwebqq,
clientid
allback eq "CODE"?0:1;
my $handle = sub{
my $json = shift;
return undef unless defined $json;
return undef if $json->{retcode}!=0 ;
my %type = (0 => 'friend',1 => '
group', 2 => 'discuss');
my @recent;
for(@{$json->{result}}){
next unless exists $type{$_->{type}};
$_->{type} = $type{$_->{type}};
if($_->{type} eq
$msg->allow_plugin(0);
my $salt = time;
$client->http_get($api,{json=>1},form=>{
q => $query,
from => 'auto',
to
b{
my $json = shift;
if( not defined $json ){$msg->reply("翻译失败: api接口不可用")}
elsif(defined $json and exists $json->{error_code}){
可用(" . $json->{error_code} . " " . $json->{error_msg} . ")");
}
elsif(defined $json){
$msg->reply( join " ",map {$_->{dst}} @{ $json->{trans_re
e Dwarf::HTTP::Async;
use DateTime;
use DateTime::Format::HTTP;
use HTTP::Request::Common ();
use JSON;
use LWP::UserAgent;
use Dwarf::Accessor qw/
ua ua_async urls
key secret
access_token access_
hod = uc $method;
$params->{access_token} ||= $self->access_token;
$params->{format} ||= 'json';
my $base_url = $command =~ /^method\//
? $self->urls->{'old_api'}
: $self->urls->{'api'
validate {
my ($self, $res) = @_;
my $content = eval { decode_json($res->decoded_content) };
if ($@) {
warn "Couldn't decode JSON: $@";
$content = $res->decoded_content;
}
if ($res->code !~
nt;
$client->http_post($api_url,
{'Authorization'=>"key=$api_key",json=>1},
json=>{
registration_ids=> $registration_ids,
$collapse_key
"message_id":"0:1484103730761325%9b9e6c13f9fd7ecd"}]}"
my $json = shift;
if(not defined $json){
$client->debug("[".__PACKAGE__."]GCM消息推送失
$client->debug("[".__PACKAGE__."]GCM消息推送完成:$json->{multicast_id}/$json->{success}/$json->{failure}");
}
}
);
});
$client
e Dwarf::HTTP::Async;
use DateTime;
use DateTime::Format::HTTP;
use HTTP::Request::Common ();
use JSON;
use LWP::UserAgent;
use Data::Dumper;
use Dwarf::Accessor qw/
ua urls
key secret
access_toke
n_error->('Amazon OAuth Error: Could not get access token.');
return;
}
my $decoded = decode_json $res->{_content};
my $access_token = $decoded->{access_token};
$self->access_token($access_tok
validate {
my ($self, $res) = @_;
my $content = eval { decode_json($res->decoded_content) };
if ($@) {
warn "Couldn't decode JSON: $@";
$content = $res->decoded_content;
}
# [todo]
# che
warf::Util qw/add_method encode_utf8 decode_utf8/;
use Email::Valid;
use Email::Valid::Loose;
use JSON;
use Mouse;
use Mouse::Util::TypeConstraints;
use Regexp::Common qw/URI/;
sub init {
my ($class
CreditcardSecurity
=> as 'Str'
=> where { $_ =~ /\A[0-9]{3,4}\z/ };
subtype JSON
=> as 'Str'
=> where { _json($_) };
subtype Base64JPEG
=> as 'Str'
=> where { _base64_type($_, 'jpeg')
$s > 59 or $s < 0 ) {
return 0;
}
return 1;
}
sub _json {
my $value = $_;
return 1 unless defined $value;
my $data = eval { decode_json encode_utf8 $value };
if ($@) {
warn $@;
warn $val
json => 1,
};
#使用http_get从API获取所需信息
$client->http_get($API.$prov,$headers,sub{
my $json = shift;
return unless defined $json;
my $resultArray = $json
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 (
package Mojo::Webqq::Util;
use Carp qw();
use Encode qw();
use IO::Handle;
use Mojo::JSON qw();
use Mojo::Util qw();
use Mojo::Webqq::Counter;
sub new_counter {
my $self = shift;
return Mojo::
from_json{
my $self = shift;
my $r = eval{
if($self->json_codec_mode == 0){
my $json = Mojo::JSON::from_json(@_);
$json;
}
elsif($self->json_cod
my $json = Mojo::JSON::decode_json(@_);
$self->reform($json);
$json;
}
else{
my $json = Mojo::JSON::from_json(@_);
$json;
ile::Spec->catfile($ENV{MOJO_WEBQQ_TMPDIR},join('','mojo_webqq_state_',$ENV{MOJO_WEBQQ_ACCOUNT},'.json')) if not defined $ENV{MOJO_WEBQQ_STATE_PATH};
$ENV{MOJO_WEBQQ_QRCODE_PATH} = File::Spec->cat
e Mojo::JSON ();
use Mojo::Util ();
use base qw(Mojolicious::Controller);
sub render{
my $self = shift;
if($_[0] eq 'json'){
$self->res->headers->content_type('application/json');
$self->SUPER::render(data=>Mojo::JSON::to_json($_[1]),@_[2..$#_]);
}
else{$self->SUPER::render(@_)}
}
sub safe_render{
my $self = shift;
$self->render(@_) if (defined $self->tx and
tle or !$message;
my $result=$client->http_post($api_url, {json=>1},
form=>{
nsp_fmt => JSON,
deviceToken => $deviceToken,
push_t
message=>$client->to_json({isAt=>$isAt,type=>$type,title=>$title,message=>$message,msgId=>$msgId,senderType=>$senderType}),
},
sub{
my $json = shift;
if(not defined $json){
$client->debug("[".__PACKAGE__."]华为消息推送失败: 返回结果异常");
return;
}
else{
is_transparent eq 1) {
$client->http_post($api_url,
{'Authorization'=>"key=$api_key",
json=>1
},
form=>{
pass_through => 1,
registration_id => $regi
t->to_json({isAt=>$isAt,type=>$type,title=>$title,message=>$message,msgId=>$msgId,senderType=>$senderType}),
},
sub{
my $json = shift;
if(not defined $json){
米消息推送状态:$json->{error}");
}
}
);
} else {
$client->http_post($api_url,
{'Authorization'=>"key=$api_key",
json=>1
},
form=>{
ge;
$client->http_post($api_url,
{'Authorization'=>"key=$api_key",json=>1},
json=>{
registration_ids=> $registration_ids,
$collapse_key
"message_id":"0:1484103730761325%9b9e6c13f9fd7ecd"}]}"
my $json = shift;
if(not defined $json){
$client->debug("[".__PACKAGE__."]GCM消息推送失
$client->debug("[".__PACKAGE__."]GCM消息推送完成:$json->{multicast_id}/$json->{success}/$json->{failure}");
}
}
);
});
$client
$json = {
"key" => $data->{apikey} || "f771372ffd054183bfcdf260d7c7ad5a",
"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}";
Referer => 'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2',
json => 1,
};
my %r = (
status => $self->mode,
ptwebqq => $s
lf->passwd_sig;
#}
my $data = $self->http_post($api_url,$headers,form=>{r=>$self->to_json(\%r)});
return 0 unless defined $data;
if($data->{retcode} ==0){
if(defined $self
/;
}
sub to_json_hash{
my $self = shift;
my $json = {};
for my $key (keys %$self){
next if substr($key,0,1) eq "_";
if($key eq "sender"){
$json->{sender} = $
ame;
$json->{sender_uid} = $self->sender->uid;
}
elsif($key eq "receiver"){
$json->{receiver} = $self->receiver->displayname;
$json->{receiver_uid}
group"){
$json->{group} = $self->group->displayname;
$json->{group_uid} = $self->group->uid;
}
elsif($key eq "discuss"){
$json->{discuss} = $self->d
t;
my $json = shift;
return if $self->is_stop;
return unless defined $json;
if ( $json->{retcode} == 0 ) {
$self->poll_failure_count(0);
for my $m ( @{ $json->{result}
#更新客户端ptwebqq值
elsif ( $json->{retcode} == 116 ) {
$self->debug("更新ptwebqq的值[ $json->{p} ]");
$self->ptwebqq($json->{p});
$self->ua->cookie_jar->ad
:Response->new(name=>"ptwebqq",value=>$json->{p},path=>"/",domain=>"qq.com",),
);
}
#未重新登录
elsif ( $json->{retcode} == 100 or $json->{retcode} == 103) {
$self->w
= {
Referer => 'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2',
json => 1,
};
my @query_string = (
newstatus => $mode,
clientid
=> time,
);
my $json = $self->http_get($self->gen_url($api_url,@query_string),$headers);
return undef unless defined $json;
return undef if $json->{retcode} !=0;
$self->mod
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;