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,(
use JSON;
use Encode;
use Webqq::Client::Util qw(code2client);
sub Webqq::Client::_get_discuss_info {
my $self = shift;
my $ua = $self->{ua};
my $did = shift;
return undef if $s
if($response->is_success){
print $response->content,"\n" if $self->{debug};
my $json;
eval{
#my $d = $response->content();
#$d=~s/\\u([a-zA-Z0-9]{4})/
$json = JSON->new->utf8->decode($response->content());
};
print $@ if $@ and $self->{debug};
$json = {} unless defined $json;
return undef if $json->{retcode}!
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 ;
use Webqq::Client::Util qw(console);
sub Webqq::Client::_login2{
my $self = shift;
console "尝试进行登录(阶段2)...\n";
my $ua = $self->{ua};
my $api_url = 'http://d.
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
2'; # VERSION
use Mojo::Base 'Mojolicious::Controller';
use experimental 'postderef';
use JSON::Meth qw/$json/;
sub login {
my $self = shift;
my $user = $self->users->check(
$self->
self->config('site') )->@*;
my @list;
for ( @prods ) {
my $pr = $_->{price_raw}->$json->{ $self->config('site') };
if ( ref $pr ) {
$pr = join ',', map "${_}_$pr->{
use JSON;
use Encode;
sub Webqq::Client::_send_sess_message{
my($self,$msg) = @_;
return unless defined $msg->{group_sig};
my $ua = $self->{asyn_ua};
my $callback = sub{
my $re
,
face => $self->{qq_database}{user}{face} || 591,
content => JSON->new->utf8->encode($content),
msg_id => $msg->{msg_id},
service_type
$s{content} = decode("utf8",$s{content});
my $post_content = [
r => JSON->new->utf8->encode(\%s),
];
if($self->{type} eq 'webqq'){
push @$post_content,(
qw/sort_by extract_by/;
use Scalar::Util qw/blessed/;
use experimental qw/postderef/;
use JSON::Meth qw/$json/;
use autobox;
sub SCALAR::split_comma { [ split /\s*,\s*/, $_[0] ] }
has [qw/pg prici
} }
$values{sites} //= 'default';
$values{price} //= { default => { '00' => '0.00' } }->$json;
return $self->pg->db->query(
'INSERT INTO products (number, image, title,
/g;
# Remove site's pricing
my $p = $_->{price}->$json;
delete $p->{ $site };
$_->{price} = $p->$json;
$self->pg->db->query(
q{UPDATE products SET
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
r::Session::CHI>,
L<Cookie|Dancer::Session::Cookie>,
L<DBIC|Dancer::Session::DBIC>,
L<JSON|Dancer::Session::JSON>,
L<Memcached|Dancer::Session::Memcached>,
L<Memcached::Fast|Dancer::Session::Memcache
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};
ackage VM::CloudAtCost;
use strict;
use warnings;
use Carp;
use LWP::UserAgent;
use JSON;
use Data::Clean::FromJSON;
use Exporter qw(import);
our $VERSION = "0.1";
sub new {
my ($class, %par
my $result = eval { from_json($response->content()) };
if ($response->is_success()) {
my $JSONcleaner=Data::Clean::FromJSON->new();
my $cleanJSON = $JSONcleaner->clean_in_place($
my $result = eval { from_json($response->content()) };
if ($response->is_success()) {
my $JSONcleaner=Data::Clean::FromJSON->new();
my $cleanJSON = $JSONcleaner->clean_in_place($
simple;
my $sm_status = $simple->sm_publish('{"say": "hello"}', content_type => "application/json");
die sm_get_error_desc($sm_status) if $sm_status;
$simple->sm_destroy();
}
sub consu
shrefs in a md5 sum.
This I will compare to later processing.
My first approach was to use encode_json string.
Unfortunately, the resort was not very consistent.
So I wrote my first cpan packet in or
ght implementation of Spore specification
use Moo;
use Sub::Install;
use Try::Tiny;
use Carp;
use JSON::MaybeXS;
use Data::Rx;
use LWP::UserAgent;
use URI;
use File::ShareDir ':ALL';
use Subclass::Of;
d => 1,
coerce => sub {
my $json_spec = $_[0];
my $spec;
# it could be a file
try {
open my $fh, '<', $json_spec or croak 'Cannot read the spec file'
spec = decode_json(<$fh>);
close $fh;
}
catch {
try {
$spec = decode_json($json_spec);
}
# it is not json, so we are re
;
my $response = Net::HTTP::Knork::Response->new(
200, ['Content-Type', 'application/json'], '{"foo":1}';
);
$response->request($request);
=head1 DESCRIPTION
Net::HTTP::Knork::R
hen the body is sets for the first time.
=item content_type
$res->content_type('application/json');
my $ct = $res->content_type;
Gets or sets the content type of the response body
=item co
ype' => 'application/json']);
Gets or sets HTTP response headers.
=item header
my $cl = $res->header('Content-Length');
$res->header('Content-Type' => 'application/json');
Shortcut for C<<
owl jquery plugin):
[% SET growl_list = growls() %]
[%- IF growl_list.size %]
[% USE JSON.Escape %]
<script type="text/javascript">
$( document ).ready(function() {
in growl_list -%]
$.bootstrapGrowl("[% growl.message.dquote %]", [% growl.options.json %]);
[% END %]
});
</script>
[%- END %]
=head1 DESCRIPTION
This all