ge Mojo::Weixin::Util;
use Carp qw();
use Encode ();
use IO::Handle;
use Mojo::Util ();
use Mojo::JSON qw();
use Mojo::Weixin::Const qw(%FACE_MAP_QQ %FACE_MAP_EMOJI);
my %emoji_to_text_map = reverse %
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;
以在http header设置一些请求相关的选项,比如:
#json=>1 表示将响应的json数据进行json decode得到perl的hash引用
#ua_retry_times=>3 表示请求
时间
#ua_inactivity_timeout 阻塞http请求idle 超时时间
my $json_decode_hash = $client->http_get($url,{json=>1,retry_times=>3,Host=>"www.qq.com"});
#http post请求
$client->
post_event => 1,
});
#接收到消息后,插件会通过HTTP POST请求的方式将json格式的消息上报到http://127.0.0.1:4000/post_api
普通好友消息或群消息上报
Import data into Solr
$ catmandu import JSON to Solr < data.json
# Export data from ElasticSearch
$ catmandu export Solr to JSON > data.json
# Export only one record
$ catmandu
$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
don't rely on it.
=head2 Operational modes
=head3 simple
Jobs are submitted by serialising as JSON and pushing to a Redis list
as a queue.
Workers retrieve jobs from queue, and send the results v
::Client>
=head1 SYNOPSIS
=head1 DESCRIPTION
=cut
no indirect;
use Syntax::Keyword::Try;
use JSON::MaybeUTF8 qw(:v1);
use Ryu::Async;
use Job::Async::Utils;
use Net::Async::Redis 1.003;
use Log:
]};
my $type = substr $result, 0, 1, '';
$result = decode_json_utf8($result) if $type eq 'J';
$log->tracef('Job result %s', $result);
ON = '0.10';
# ABSTRACT: WHMCS API Role
use Moo::Role;
use Carp 'croak';
use LWP::UserAgent;
use JSON;
has 'WHMCS_URL' => (
is => 'rw',
required => 1
);
has 'api_identifier' => (is =>
= $self->WHMCS_API_ACCESSKEY if $self->WHMCS_API_ACCESSKEY;
}
$params->{responsetype} = 'json';
my $resp = $self->ua->post($self->WHMCS_URL, $params);
return {
result => 'er
} unless $resp->is_success;
# print Dumper(\$resp); use Data::Dumper;
return decode_json($resp->content);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Net::WHMCS::Base - WHMCS API
my $pos = $recce->read( \$string ); $pos < $length...)
my $per_parse_arg = bless {}, 'MarpaX::JSON::Actions';
my $value_ref = $recce->value($per_parse_arg);
return ${$value_ref};
=for Mar
::Keyword::Try;
use Future::AsyncAwait;
use Job::Async::Utils;
use Future::Utils qw(repeat);
use JSON::MaybeUTF8 qw(:v1);
use Log::Any qw($log);
use Net::Async::Redis;
=head2 incoming_job
Source f
processed => Time::HiRes::time(),
result => ref($rslt) ? 'J' . encode_json_utf8($rslt) : 'T' . $rslt
),
$tx->publish('client
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=>'
ateTime::Format::ISO8601::Format;
use JSON;
use Net::Prometheus::Types qw(MetricSamples Sample);
use Parallel::Scoreboard;
our $VERSION = "0.02";
my $JSON = JSON->new->utf8(0);
my $dt_formatter = Da
> $dt_formatter,
time_zone => 'America/Los_Angeles',
)->stringify;
print STDERR $JSON->encode({
category => 'Plack',
middleware => __PACKAGE__,
level =>
k scoreboard stats is valid
my @all_workers = keys %$stats;
my $pstatus = eval {
$JSON->decode($stats->{$all_workers[0]} || '{}');
};
if (!$pstatus->{ppid} || !$pstatus->{uptim
user.name,
user.username,
(
select
json_group_array(item)
from (
select json_object(
'id', items.id,
'title', i
r.username=?
SQL
return $self
->sqlite
->db
->query($sql, $username)
->expand(json => 'items')
->hash;
}
sub all_users {
my $self = shift;
return $self
->sqlite
->
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_
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
ost_json = {};
$post_json->{post_type} = "event";
$post_json->{event} = $event;
$post_json->{params} = [@args];
$client->stdout_line($client->to_json($p
ost_json)) if $data->{post_stdout};
if(defined $data->{post_api}){
my($data,$ua,$tx) = $client->http_post($data->{post_api},{ua_connect_timeout=>5,ua_request_timeout=>5,ua_
inactivity_timeout=>5,ua_retry_times=>1},json=>$post_json);
if($tx->res->is_success){
$client->debug("插件[".__PACKAGE__ ."]事件[".$event . "](@args)上报成
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
};
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->{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
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 $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