ommunicate with the API and returns the results in the 3
possible formats (provided by Ipernity): JSON, XML, SOAP, XML-RPC
=head1 METHODS
=over 4
=item B<new>( configuration arguments )
The constr
* HASH_ELEMENT
* HREF_PARAM
* HTMLESCAPE
* ICONV
* IN_SET
* JSESCAPE
* JSON
* LIST_ELEMENT
* LOG
* MD5
* MAX
* MB_SIZE
* MB_SUBSTR
* MB_TRUNCATE
parameters to undef.
$T -> clear_params();
or
$T -> reset();
=head2 json_param() - set some parameters
$T -> json_param('{ "foo": "bar", "baz" : 123}');
=head2 output() - returns output as
P2ErrorCodes.h>
#include <CTPP2Exception.hpp>
#include <CTPP2FileSourceLoader.hpp>
#include <CTPP2JSONParser.hpp>
#include <CTPP2Logger.hpp>
#include <CTPP2Parser.hpp>
#include <CTPP2ParserException.h
// Reset parameters
int reset();
// Reset parameters
int clear_params();
// Emit JSON parameters
int json_param(SV * pParams);
// Get output
SV * output(Bytecode * pBytecode,
// Emit JSON parameters
int CTPP2::json_param(SV * pParams)
{
using namespace CTPP;
long eSVType = SvTYPE(pParams);
STRLEN iJSONLen = 0;
#ifdef SvPV_const
const char * szJSON = NULL;
::Apache::RewriteRules;
use 5.008001;
use strict;
use warnings;
use Carp qw(croak);
use JSON::XS qw(decode_json);
use Path::Class qw(dir file);
use File::Temp qw(tempfile);
use LWP::UserAgent;
use H
r = <<"EOS";
#!/usr/bin/env perl
use strict;
use warnings;
use JSON::XS;
print "Content-Type: application/json;\\n\\n";
print encode_json({
host => \$ENV{HTTP_HOST},
path
>header('Location') if $res->header('Location');
}
else {
$result = eval { decode_json($res->content) };
die $@ if $@;
$result->{code} = $code;
$result->{host}
::Request::History;
use WebService::VaultPress::Partner::Request::Usage;
use Moose;
use Carp;
use JSON;
use LWP;
use Moose::Util::TypeConstraints;
my $abs_int = subtype as 'Int', where { $_ >= 0 };
>_croak_on_http_error( $res );
my $json = decode_json( $res->content );
# The API tells us if the call failed.
die $json->{reason} unless $json->{status};
return WebService::Vau
new(
api_call => 'CreateGoldenTicket',
ticket => exists $json->{url} ? $json->{url} : "",
);
}
sub get_usage {
my ( $self, %request ) = @_;
my $req
y/application/my_application_local.{yml,yaml,cnf,conf,jsn,json,...} AND
path/to/my/application/my_application.{yml,yaml,cnf,conf,jsn,json,...}
... and load the found configuration information ap
ing json files
B<not implemented yet>
Ensure you have json files:
json/en.json
json/fr.json
json/ja.json
Then specify the C<json> option:
$hl = I18N::Handle->new( json => 'json' )
Twitpic;
use warnings;
use strict;
use utf8;
use LWP::UserAgent;
use HTTP::Request::Common;
use JSON;
use Net::OAuth;
our $DYNAMIC_FILE_UPLOAD = 1;
=head1 NAME
Net::Twitpic - The great new Net::Tw
request_method => 'GET',
request_url => 'https://api.twitter.com/1/account/verify_credentials.json'
);
$oauth_sign->sign;
my %uploadparams = (
'key' => $self->{'twitpic_api'},
'message' =>
ps://api.twitter.com/1/account/verify_credentials.json',
'Content-Type' => 'form-data'
);
my $request = POST('http://api.twitpic.com/2/upload.json',\%uploadparams,%req_headers);
$self->{r} = $sel
NOPSIS
use WWW::Lovefilm::API;
use XML::Simple;
use Data::Dumper;
use URI::Escape;
use JSON;
my %auth = Your::Custom::getAuthFromCache();
my $lovefilm = WWW::Lovefilm::API->new({
$auth{access_secret},
user_id => $auth{user_id},
content_filter => sub { decode_json(shift) }, # optional
});
if( ! $auth{user_id} ){
my %data = $lovefilm->RequestToken();
document root.
# 2010 by Tom Kirchner
use 5.010000;
use strict;
use warnings;
use IO::File;
use JSON;
use Path::Trim;
use HTTP::AppServer::Plugin;
use base qw(HTTP::AppServer::Plugin);
our $VERSION
{
$ret ~= %s{'object'} ~ ".";
}
# Should use JSON to build arglist.
my $args = %s{'args'}.join(",");
$ret ~= %s{'ca
ION = '0.01';
use WebService::8tracks::Session;
use WebService::8tracks::Response;
use JSON::XS qw(decode_json);
use URI::Escape qw(uri_escape uri_escape_utf8);
use HTTP::Request;
our @CARP_NOT = (
sub api_url {
my ($self, $path, $qparam) = @_;
my $url = "http://api.8tracks.com/$path.json";
if ($qparam) {
if (ref $qparam eq 'HASH' && scalar keys %$qparam) {
my
->password);
}
my $res = $self->user_agent->request($req);
my $api_response = decode_json $res->content;
return WebService::8tracks::Response->new($api_response);
}
=head1 METHODS
=
mark> and gives you human-readable reports
as a reply rather than a raw hashref, it also supports JSON output if
you want to dump the report somewhere in a machine-readable format.
If you have no tem
ION = '0.01';
use WebService::8tracks::Session;
use WebService::8tracks::Response;
use JSON::XS qw(decode_json);
use URI::Escape qw(uri_escape uri_escape_utf8);
use HTTP::Request;
our @CARP_NOT = (
sub api_url {
my ($self, $path, $qparam) = @_;
my $url = "http://api.8tracks.com/$path.json";
if ($qparam) {
if (ref $qparam eq 'HASH' && scalar keys %$qparam) {
my
->password);
}
my $res = $self->user_agent->request($req);
my $api_response = decode_json $res->content;
return WebService::8tracks::Response->new($api_response);
}
=head1 METHODS
=
package HTTP::AppServer::Plugin::JsonCrud;
# Plugin for HTTP::AppServer that provides CRUD methods for
# storing JSON documents in a DBI (relational) database.
# 2010 by Tom Kirchner
################
se DBI;
use JSON;
use HTTP::AppServer::Plugin;
use base qw(HTTP::AppServer::Plugin);
our $VERSION = '0.01';
# database connection settings
my $DBEngine = 'mysql';
my $DBName = 'jsondb';
my $DB
ot';
my $DBPassword = '';
my $DBHost = 'localhost';
# database settings
my $DBTablePrefix = 'jsondb_';
# UUID generator instance
my $UUIDGenerator = Data::UUID->new();
# called by the server wh
self->{statements} }, { code => args };
return self;
},
'""' => \&as_string;
use JSON::Syck;
our $VERSION = '0.3.1';
use Sub::Exporter -setup => {
exports => ['js'],
groups
v)
}
return "{" . join (",", map { JSON::Syck::Dump($_) . ":" . $ret{$_} } sort keys %ret) . "}";
}
else {
return JSON::Syck::Dump($obj)
}
}
sub as_string {
my
given in
perl's native form, you don't need to use L<JSON> module to serialized
it first. (Unless, of course, that's your purpose: to get a JSON
string in JavaScript.)
=item var( $name, [ $value ]
RUD server for JSON objects and plain files.
# 2010 by Tom Kirchner
#
# routes:
# POST /create = erzeugt neues JSON-Dokument, liefert UUId zurueck
# GET /read/<uuid> = liefert JSON-Dokument oder
Fehler zurueck
# POST /update/<uuid> = aendert JSON-Dokument (erzeugt neue Revision)
# GET /delete/<uuid> = loescht JSON-Dokument
# GET /file/<filename> = gibt Datei innerhalb Document-Root z
ackage JavaScript::Writer::Var;
use strict;
use warnings;
our $VERSION = '0.0.2';
use self;
use JSON::Syck;
sub new {
my ($class, $ref, $params) = @_;
tie $$ref, $class, $$ref, $params;
~ (/^JavaScript::Writer/)) {
$v = self->{value}->as_string;
}
else {
$v = JSON::Syck::Dump( self->{value} );
}
$v =~ s/\.?;?$/;/;
my $s = self->{name} . " = $v" ;
le assignement, it'll be written
as a javascript assignment too. Only the value are dumped with
C<JSON::Syck>.
=back
=head1 AUTHOR
Kang-min Liu C<< <gugod@gugod.org> >>
=head1 LICENCE AND COPYRI
... } );
1;
For example, if you are in Dancer:
#!/usr/bin/perl
use Dancer;
use JSON;
our $m = Web::API::Mapper->new
->mount( '/twitter' => Twitter::API->route )
strict;
use 5.008_001;
our $VERSION = '0.05';
use AnyEvent;
use AnyEvent::HTTP;
use Encode;
use JSON;
use MIME::Base64;
use Scalar::Util;
use URI;
use URI::QueryParam;
sub new {
my($class, %arg
_poll->() unless $body;
my $res = eval { JSON::decode_json($body) } || do {
($args{on_error} || sub { die @_ })->("JSON parsing error: $@");
return;
ent::FriendFeed::Realtime is an AnyEvent consumer that subscribes
to FriendFeed Real-time API via JSON long-poll.
=head1 AUTHOR
Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>
=head1 LICENSE
Th