package Amon2::Auth::Site::Hatena;
use Mouse;
use JSON;
use OAuth::Lite::Token;
use OAuth::Lite::Consumer;
use Woothee;
our $VERSION = '0.04';
has consumer_key => (
is => 'ro',
isa
(
is => 'ro',
isa => 'Str',
default => 'http://n.hatena.com/applications/my.json',
);
has redirect_url => (
is => 'ro',
isa => 'Str',
);
no Mouse;
__PACKAGE__->meta->m
fo_url);
return $error->($self->ua->errstr) if $res->is_error;
my $data = decode_json($res->decoded_content);
push @args, $data;
}
$callback->{on_finished}->(@args);
OBJET : Exemple d'utilisation de CTM::ReadEM : simple recuperation des services du BIM au format JSON
# APPLICATION : ControlM
# AUTEUR : Yoann Le Garff
# DATE DE CREATION : 20/07/2014
#-------------
use warnings;
use strict;
use Getopt::Long;
use File::Basename qw/basename/;
use Try::Tiny;
use JSON;
use CTM::ReadEM 0.181, qw/:all/;
#----> ** fonctions **
sub usage() {
return 'Aide : perld
service_name => sub {
shift =~ $opts{f}
}
});
}
print JSON->new()->utf8()->pretty()->encode($servicesObj->getItems()) . "\n";
} else {
die $err;
}
exit
package Amon2::Auth::Site::Google;
use Mouse;
use JSON;
use LWP::UserAgent;
use URI;
our $VERSION = "0.04";
has client_id => (
is => 'ro',
isa => 'Str',
required => 1,
);
ha
ent;
return $callback->{on_error}->($res->decoded_content);
};
my $token = decode_json $res->content;
my $uri = URI->new($self->token_info_url);
$uri->query_form(+{ access_tok
token->{access_token} });
$res = $self->ua->get($uri->as_string);
my $token_info = decode_json $res->content;
$res->is_success or do {
warn $res->decoded_content;
return $c
'Email', 'Phone', 'Mobile',
'Comments', 'Fax', 'Url'
);
sub TO_JSON { return { %{ $_[0] } }; }
no Moo;
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Business::e
ngs;
use parent qw( SMS::Send::Driver );
use DateTime;
use Digest::HMAC_MD5;
use HTTP::Tiny;
use JSON;
use String::Random;
our $URL = "https://api.coolsms.co.kr/sms/1.1";
our $AGENT = 'SMS-Sen
id response for GET request';
if ( $res && $res->{success} ) {
$ret{detail} = decode_json( $res->{content} );
$ret{reason} = 'OK';
$ret{success} = 1;
}
else {
id response for POST request';
if ( $res && $res->{success} ) {
$ret{detail} = decode_json( $res->{content} );
$ret{reason} = $ret{detail}{result_message};
$ret{success} =
rAgent;
use JSON qw(decode_json encode_json);
use Time::HiRes qw/gettimeofday/;
use Data::Dumper;
} else {
use LWP::UserAgent;
use JSON qw(decode_json encode_json);
use Time:
>{'last_reason'} = '';
$self->{'device_url'} = "https://developer-api.nest.com/devices.json?auth=".$self->{'auth_token'};
$self->{'last_exec_time'} = 0;
if (!defined $self->{'debu
= $response->code;
if ($response->is_success) {
my $decoded_response = decode_json($response->content);
my $designation = ($decoded_response->{'thermostats'});
te qw/inflate/;
use IO::Uncompress::Bunzip2 qw/bunzip2/;
use List::Util qw/sum/;
use JSON::MaybeXS qw/decode_json/;
use UUID::Tiny qw/uuid_to_string/;
use constant HEADER_SPEC => [
[signature
at version' if $header{version} != 1;
read $fh, my $meta, $header{meta_length};
$meta = decode_json decompress $meta;
my %obj = (
%header,
fh => $fh,
meta => $meta,
index_format => ($head
ak |;
use Data::Dump qw| dump |;
use Encode qw| encode_utf8 |;
use IO::Handle;
use JSON::XS qw| decode_json |;
use Sys::Cmd qw| spawn |;
use Try::Tiny;
sub read_games {
my $pgn = shift;
xtract', '-s', '-Wjson', $pgn );
my $out = do { local $/; $proc->stdout->getline };
my @err = $proc->stderr->getlines;
if (@err) {
if ($err[0] =~ /Unknown output format json/) {
croak
r: pgn-extract has no '-Wjson' option");
}
STDERR->print ("pgn-extract: $_") for @err;
}
$proc->wait_child; # cleanup
# Ad-hoc hack for a problem in parsing JSON
#
# PGN files may c
erver::Ident> 1.16
=head3 L<POE::Component::Server::Inet> 0.06
=head3 L<POE::Component::Server::JSONRPC> 0.05
=head3 L<POE::Component::Server::MySQL> 0.02
=head3 L<POE::Component::Server::NNTP> 1.
Filter::IRCD> 2.44
=head3 L<POE::Filter::IRCv3> 1.001001
=head3 L<POE::Filter::JSON> 0.04
=head3 L<POE::Filter::JSON::Incr> 0.03
=head3 L<POE::Filter::KennySpeak> 1.02
=head3 L<POE::Filter::LOLCA
ttp://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/> and
basicer at Bitbucket for
L<his work on JSON enhancement|https://bitbucket.org/basicer/pgn-extract/>.
=head1 LICENSE
Copyright (C) 2014 Mits
=head1 DESCRIPTION
It is often desirable to create an object from a database row or a decoded
JSON object. However, it is quite likely that you might have declared some
attributes with C<< init_ar
:ClickSend;
use strict;
use 5.008_005;
our $VERSION = '0.02';
use Carp;
use LWP::UserAgent;
use JSON;
use MIME::Base64;
use HTTP::Request;
use vars qw/$errstr/;
sub errstr { $errstr }
sub new {
($self, $url, $method, $params) = @_;
$url = 'https://api.clicksend.com/rest/v2/' . $url . '.json';
$params ||= {};
$params->{method} = 'rest'; # we prefer rest
my $uri = URI->new($
st($req);
if (not $res->header('Content-Type') =~ /json/) {
$errstr = $res->status_line;
return;
}
return decode_json($res->decoded_content);
}
1;
__END__
=encoding utf-
package WebService::MusixMatch;
use JSON::XS;
use Cache::LRU;
use Net::DNS::Lite;
use Furl;
use URI;
use URI::QueryParam;
use Carp;
use Moo;
use namespace::clean;
our $VERSION = "0.06";
$Net::DNS::L
RI->new;
$query->query_param( 'apikey', $self->api_key );
$query->query_param( 'format', 'json' );
map { $query->query_param( $_, $query_param->{$_} ) } keys %$query_param;
my ($minor
ath_query => "ws/1.1/$path$query",
method => 'GET',
);
my $data = decode_json( $content );
if ( $data->{message}{header}{status_code} != 200 ) {
confess $data->{me
package ArangoDB2::Base;
use strict;
use warnings;
use Carp qw(croak);
use Data::Dumper;
use JSON::XS;
use Scalar::Util qw(blessed weaken);
# new
#
# Arango organizes data hierarchically: Databas
value or set JSON bool value.
# setting value returns self.
sub _get_set_bool
{
my($self, $param, $value, $validate) = @_;
if (defined $value) {
# accept "true" as JSON bool false
eq "true") {
$value = JSON::XS::true;
}
# accept "false" as JSON bool false
elsif ($value eq "false") {
$value = JSON::XS::false;
}
# u
package WebService::GigaTools;
use JSON::XS;
use Cache::LRU;
use Net::DNS::Lite;
use Furl;
use URI;
use URI::QueryParam;
use Carp;
use Moo;
use namespace::clean;
our $VERSION = "0.01";
$Net::DNS::Li
my $code = sub {
my ($self, %query_param) = @_;
return $self->request("$method.json", \%query_param);
};
no strict 'refs';
*{$method} = $code;
}
sub request {
my
path_query => "$path$query",
method => 'GET',
);
my $data = decode_json( $content );
if ( $status_code != 200 ) {
confess "Error";
} else {
retur
warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
use URI::Escape qw(uri_escape);
my $JSON = JSON::XS->new->utf8;
###############
# API METHODS #
###############
#
equest
my $res = $self->arango->http->post(
'/_api/endpoint',
undef,
$JSON->encode($args),
) or return;
# if request was success copy args to self
$self->_build
use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
my $JSON = JSON::XS->new->utf8;
my @PARAMS = qw(
direction edgeCollection expander filter graphNa
return $self->arango->http->post(
$self->api_path('traversal'),
undef,
$JSON->encode($args),
);
}
# expander
#
# get/ set expander
sub expander { shift->_get_set('expand
rator function with this attribute. Note that the value here has to be a string to conform to the JSON standard, which in turn is parsed as function body on the server side. Furthermore note that this
use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
my $JSON = JSON::XS->new->utf8;
# action
#
# get/set action
sub action { shift->_get_set('action',
return $self->arango->http->post(
$self->api_path('transaction'),
undef,
$JSON->encode($args),
);
}
# lockTimeout
#
# get/set lockTimeout
sub lockTimeout { shift->_get_set
JSON::XS;
use Scalar::Util qw(reftype);
use ArangoDB2::Collection;
use ArangoDB2::Graph;
use ArangoDB2::Query;
use ArangoDB2::Replication;
use ArangoDB2::Transaction;
use ArangoDB2::User;
my $JSON
= JSON::XS->new->utf8;
# collection
#
# get/create ArangoDB2::Collection object
sub collection
{
my($self, $name) = @_;
if (defined $name) {
# only create one ArangoDB2::Collection
equest
my $res = $self->arango->http->post(
'/_api/database',
undef,
$JSON->encode($args),
) or return;
return $self;
}
# current
#
# GET /_api/database/current
s
use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
my $JSON = JSON::XS->new->utf8;
# create
#
# POST /_api/document
#
# Query Parameters
#
# collectio
$res = $self->arango->http->post(
$self->api_path($self->_class),
$args,
$JSON->encode($data),
) or return;
# copy response data to instance
$self->_build_self($res
$self->api_path($self->_class, $self->collection->name, $self->name),
$args,
$JSON->encode($data),
) or return;
# copy response data to instance
$self->_build_self($res