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 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_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
package Webqq::Message;
use Webqq::Message::Face;
use JSON;
use Encode;
use Webqq::Client::Util qw(console code2client);
use Scalar::Util qw(blessed);
sub reply_message{
my $client = shift;
my
= shift;
my ($json_txt) = @_;
my $json = undef;
eval{$json = JSON->new->utf8->decode($json_txt)};
console "解析消息失败: $@ 对应的消息内容为: $json_txt\n" if $@ and
$client->{debug};
if(ref $json eq 'HASH' and $json->{retcode}==0){
return {is_success=>1,status=>"发送成功"};
}
else{
return {is_success=>0,status=>"发送失败"};
use JSON;
sub Webqq::Client::_recv_message{
my $self = shift;
return if $self->{is_stop};
my $ua = $self->{asyn_ua};
my $api_url = ($self->{qq_param}{is_https}?'https':'http') . '://d.
$r{key} = 0;
$r{ids} = [];
}
my $post_content = [
r => JSON->new->utf8->encode(\%r),
];
if($self->{type} eq 'webqq'){
push @$post_content,(
use JSON;
use Webqq::Client::Util qw(console);
sub Webqq::Client::_relink{
my $self = shift;
$self->{login_state} = 'relink';
console "正在进行重新连接...\n";
my $ua = $self->{
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
package Webqq::Client;
use strict;
use JSON;
use Encode;
use Time::HiRes qw(gettimeofday);
use LWP::Protocol::https;
use Storable qw(dclone);
use List::Util qw(first);
use base qw(Webqq::Message Webqq
use JSON;
use Webqq::Client::Util qw(console);
sub Webqq::Client::change_state{
my $self = shift;
return undef if $self->{type} ne 'smartqq';
my $state = shift;
my $api_url = 'http://d
response->content(),"\n" if $self->{debug};
my $json = JSON->new->utf8->decode( $response->content() );
return undef if $json->{retcode} !=0;
console "登录状态已修改
package Webqq::Client::Plugin::SmartReply;
use JSON;
use AE;
use Encode;
use POSIX qw(strftime);
use Webqq::Client::Util qw(truncate console);
my $API = 'http://www.tuling123.com/openapi/api';
my %lim
ring,"\n";
}
my $reply;
my $data = {};
eval{
$data = JSON->new->utf8->decode($res->content);
};
if($@){
print $@,"\n" if $clien
package Webqq::Client::Plugin::Perldoc;
use JSON;
use Webqq::Client::Util qw(console_stderr truncate);
if($^O !~ /linux/){
console_stderr "Webqq::Client::App::Perldoc只能运行在linux系统上\
e_api . $module,(),sub{
my $response = shift;
my $doc;
my $json;
my $code;
if($client->{debug}){
print "GET " . $metacpan
ponse->content;
}
eval{ $json = JSON->new->utf8->decode($response->content);};
unless($@){
if($json->{code} == 404){
return 0;
use JSON;
sub Webqq::Client::_get_recent_info {
my $self = shift;
my $ua = $self->{ua};
return undef if $self->{type} ne 'smartqq';
my $api_url = 'http://d.web2.qq.com/channel/get_re
a->post($api_url,[r=>JSON->new->utf8->encode(\%r)],@headers);
if($response->is_success){
print $response->content(),"\n" if $self->{debug};
my $json = JSON->new->utf8->decode($
());
return undef if $json->{retcode}!=0 ;
my %type = (0 => 'friend',1 => 'group', 2 => 'discuss');
my @recent;
for(@{$json->{result}}){
next unless
w(
extractHelpCreo3
);
use POSIX;
use Tie::File;
use utf8;
use Term::ProgressBar;
use JSON::Parse 'parse_json';
use IO::HTML;
use HTML::TreeBuilder 5 -weak;
use File::Basename;
use CAD::Firemen;
us
$progress->minor(0);
my $i = 0;
my $json;
foreach my $line (@toc){
my $line = strip($line);
if($i != 0 && substr($line, 0, 1) ne ";"){
$json .= $line ."\n";
}
$i++;
$pr
gress->update($lines);
}
print "\n";
my $jsonContent = parse_json($json);
if(!$jsonContent || !exists($jsonContent->{"words"}) || !exists($jsonContent->{"pages"})){
return (0, "Could not
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
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,(
use JSON;
sub Webqq::Client::_get_group_list_info{
my $self = shift;
my $ua = $self->{ua};
my $api_url = 'http://s.web2.qq.com/api/get_group_name_list_mask2';
my @headers = $self->{ty
webqq => $self->{qq_param}{vfwebqq},
);
my $post_content = [
r => JSON->new->encode(\%r),
];
#if($self->{debug}){
# require URI;
# my $uri = URI
f $self->{debug};
my $json = JSON->new->utf8->decode( $response->content() );
return undef unless exists $json->{result}{gnamelist};
return $json->{result};
}
else{ret
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 Carp;
use Data::Dumper qw/Dumper/;
use English qw/ -no_match_vars /;
use TryCatch;
use JSON qw/decode_json/;
extends 'W3C::SOAP::Client';
our $VERSION = version->new('0.007');
has _response =>
t );
}
elsif ( $type eq 'application/json' ) {
# process JSON
$content = decode_json($content);
}
elsif ( $type eq 'text
Win32"){
use LWP::UserAgent;
use HTTP::Request;
use Time::Local;
use JSON qw(decode_json encode_json);
use MIME::Base64 (qw(encode_base64));
use Time::HiRes (qw/gettimeofday/);
} else {
use LWP::UserAgent;
use HTTP::Request;
use Time::Local;
use JSON qw(decode_json encode_json);
use MIME::Base64 (qw(encode_base64));
use Time::HiRes (qw/gettimeofday/);
ponse->content eq '') { # work around for JSON module which does not handle blank content well
return "";
} else {
return decode_json($response->content);
}
} else {
aits;
use W3C::SOAP::WADL::Meta::Method;
use MooseX::Types::Moose qw/Str Int HashRef/;
use JSON qw/decode_json/;
use W3C::SOAP::Utils qw/ns2module/;
use TryCatch;
Moose::Exporter->setup_import_method
It supports less
features (currently only supports sending/receiving Riap request and response in
JSON encoding, no encryption, no authentication, no sending of logging
messages). It is suitable for l
he following format:
"j" <JSON> <CRLF>
That is, the lowercase letter C<j> followed by JSON data (must all be in one
line), followed by CRLF.
=head2 Response
"j" <JSON> <CRLF>
That is, the lower
case letter C<j> followed by enveloped result encoded in JSON
(will all be in one line) and a single <CRLF>. The next request can then be sent
by client.
If client/server sends an invalid request/res