t_fileextension\",\"_charset_\":\"utf-8\"},\"_charset_\":\"utf-8\"},{\"url\":\"$content_path.save.json\",\"method\":\"POST\",\"_charset_\":\"utf-8\"}]']";
return "post $base_url/system/batch $post
urn "post $base_url/system/world/create $post_variables";
}
#}}}
#{{{sub add_eval
# TODO: check JSON that is returned for success, as a 200 status code is
# returned even if the world is not success
ings;
our $VERSION = '1.005';
use constant API_URI => 'https://api.sailthru.com';
use LWP;
use JSON::XS;
use URI::Escape;
use HTTP::Request;
use Digest::MD5 qw( md5_hex);
use Params::Validate qw( :
ata->{'format'} = 'json';
$data->{'sig'} = $self->_getSignatureHash($data);
my $result = $self->_httpRequest( API_URI . "/" . $action, $data, $method );
my $json = JSON::XS->new->ascii->pr
etty->allow_nonref;
my $decoded = $json->decode( $result->content );
return $decoded ? $decoded : $result;
}
sub _httpRequest {
validate_pos( @_, { type => HASHREF }, { type => SCALAR }, { type =>
ess::JSONify;
## Forking JSON encoder.
## Process refs, encode JSON, return to master and die.
## Pass me a reference:
## ->put([ $json, $network, $server_name ])
## Get back JSON:
## [ $json, $ne
twork, $server_name ]
use strict;
use warnings;
use IRC::Indexer::Output::JSON;
use Storable qw/nfreeze thaw/;
use Compress::Zlib qw/memGzip/;
use bytes;
sub worker {
$0 = "ircindexer ENCODE" u
my $jsify = IRC::Indexer::Output::JSON->new(
Input => $hash,
);
my $json = $jsify->dump;
my $gzipped = memGzip($json);
my $frozen = nfreeze( [ $
he distribution.
=head1 JSON SERVER
L<ircindexer-server-json> can be used to manage a set of trawlers,
exporting JSON over HTTP for use by frontends.
Note that server-json only reports networks &
d storage.
Assuming your ircindexer-server-json is running on port 8700 on
localhost:
=head2 Retrieve available networks
use LWP::UserAgent;
use JSON::XS;
my $response = LWP::UserAgent->n
my $networks;
if ($response->success) {
my $json = $response->content;
$networks = decode_json($json);
} else {
## Retrieving JSON failed ...
## You can check for $response->c
SIS
## Pull stats from a single server:
$ ircindexer-single -s irc.cobaltirc.org -f JSON -o cobaltirc.json
## Generate some example confs:
$ ircindexer-examplecf -t httpd -o httpd.cf
$ $ED
$ $EDITOR cobaltirc/eris.oppresses.us.server
. . .
## Spawn a httpd serving JSON:
$ ircindexer-server-json -c httpd.cf
## See IRC::Indexer::Trawl::Bot for more on using trawlers from
#
rver-json> serves as a real world example of how to use
the trawler system to index IRC networks; it is usable as-is to trawl
sets of IRC servers belonging to configured networks and serve JSON-seri
$profile_update_json =
"{\"elements\":{\"$field\":{\"value\":\"$value\"}}}";
my $post_variables =
"\$post_variables = [':content','$profile_update_json',':contentType','json',':operation','
s','true']";
return
"post $base_url/~$act_on_user/public/authprofile/$profile_section.profile.json $post_variables";
}
#}}}
#{{{sub profile_update_eval
sub profile_update_eval {
my ($res) =
Output::JSON;
# or: use IRC::Indexer::Output::YAML;
# or: use IRC::Indexer::Output::Dumper;
## Convert trawler output into JSON, for example:
my $output = IRC::Indexer::Output::JSON->new(
as L<IRC::Indexer::Output::JSON>.
=head1 METHODS
=head2 new
Create an output encoder; the reference to serialize must be specified:
my $out = IRC::Indexer::Output::JSON->new(
Input => $ref,
);
=head2 dump
Return the serialized output as a scalar.
my $json = $out->dump;
=head2 write
Write serialized output to a file path or an opened FH.
$out->write($path);
Will croak() on er
qw(sum max min);
use List::MoreUtils qw(any part uniq);
use Hash::Merge qw(merge);
use JSON qw(to_json from_json);
require YAML::Any;
use Carp;
use Data::Dumper;
sub new {
my ($self, $client, $
.json";
my $data;
if (-e $cache_file) {
local $/;
eval {
open( my $fh, '<', $cache_file );
my $json_text = <$fh>;
$data = from_json( $json
self->{config}->{cache_dir} . "/buildings.json";
$self->{cache}->{cache_time} = time;
if(open( my $fh, '>', $cache_file)) {
print $fh to_json($self->{cache});
close $fh;
ay be serialized thusly:
my $ser = $dm->freeze({ format => 'JSON' });
# later
my $dm = Data::Manager->thaw($ser, { format => 'JSON' });
This is possible thanks to the magic of L<MooseX::Storag
__content()->{$page};
if (! defined $content) {
$content = $self->_ws()->_response_decoded_json($self->_request($page));
$self->__content()->{$page} = $content;
}
return $content;
}
w(Class::Accessor);
use Cache::FileCache;
use Carp;
use File::Spec::Functions qw(tmpdir);
use JSON;
use LWP::ConnCache;
use LWP::UserAgent;
use WebService::Flixster::Actor;
use WebService::Flixs
ecoded_json {
my $self = shift;
my $request = shift;
my $content = $self->_response_decoded_content($request);
my $json = JSON->new();
$json->utf8(0);
my $resp = $json->deco
d $e ) {
$self->event('recv_event', $e->getType(), $e->serialize('json'));
$self->event('event_'. $e->getType(), $e->serialize('json'));
}
}
=head2 is_connected
=cut
sub is_connected {
m
',
fields => [qw(code text)],
},
);
use namespace::clean;
use Moose;
extends 'JSON::RPC::LWP';
has client => (
is => 'ro',
isa => 'Games::Lacuna::Client',
required => 1,
w
se
DateTime
Exception::Class
FindBin
HTTP::Request
HTTP::Response
IO::Interactive
JSON::RPC::Common
JSON::RPC::LWP
LWP::UserAgent
Math::Round
MIME::Lite
Moose
Number::Format
Scalar::Util
package Net::Twitter::Stream;
use strict;
use warnings;
use IO::Socket;
use MIME::Base64;
use JSON;
use IO::Socket::SSL;
our $VERSION = '0.28';
1;
=head1 NAME
Using Twitter's streaming api.
=head1
2651' );
sub got_tweet {
my ( $tweet, $json ) = @_; # a hash containing the tweet
# and the original json
print "By: $tweet->{user}{screen_name}\n";
/filter.json api call can be use to track up to 200 keywords
and to follow 200 users.
HTTP Basic authentication is supported (no OAuth yet) so you will need
a twitter account to connect.
JSON format
:Util::TypeConstraints';
#use Mouse;
#use Mouse::Util::TypeConstraints;
use LWP::UserAgent;
use JSON;
#use URI;
use URI::Escape;
use Ouch qw(:traditional);
use Regexp::Common qw /URI/;
our $VERSION
veloper specifies in pixels.
=head3 format (default: json)
The response format – Accepted values: (xml, json)
=head3 callback
Returns a (jsonp) response format. The callback is the name of the j
rent.
=head3 allowscripts (default: false)
By default Embedly does not return script embeds for jsonp requests. They just don’t work and cause lots of issues. In some cases, you may need the scrip
package Net::Twitter::Stream;
use strict;
use warnings;
use IO::Socket;
use MIME::Base64;
use JSON;
use IO::Socket::SSL;
our $VERSION = '0.28';
1;
=head1 NAME
Using Twitter's streaming api.
=head1
2651' );
sub got_tweet {
my ( $tweet, $json ) = @_; # a hash containing the tweet
# and the original json
print "By: $tweet->{user}{screen_name}\n";
/filter.json api call can be use to track up to 200 keywords
and to follow 200 users.
HTTP Basic authentication is supported (no OAuth yet) so you will need
a twitter account to connect.
JSON format
N) {
$uri->path(sprintf("/iphone/api/v1/actors/%d.json", $self->_id()));
} elsif ($page == PAGE_PHOTOS) {
$uri->path("/iphone/api/v1/photos.json");
$uri->query_form('actor' => $self->_id(), 'li
v1/actors/%d.json", $id));
my $content = $self->_ws()->_response_decoded_content(GET $uri->as_string());
if ($content =~ m/^\s*$/) {
croak "Resource not found";
}
my $json = $self->_ws
()->_response_decoded_json(GET $uri->as_string());
if ($json->{'id'} ne $id) {
die "id failed round trip"
}
return $id;
} elsif (exists $self->_q()->{'imdbid'}) {
my $imdbid = $self->_
he::FileCache;
use Carp;
use File::Spec::Functions qw(tmpdir);
use HTTP::Request::Common;
use JSON;
use LWP::ConnCache;
use LWP::UserAgent;
use WebService::IMDB::Title;
use WebService::IMDB::Nam
ecoded_json {
my $self = shift;
my $request = shift;
my $content = $self->_response_decoded_content($request);
my $json = JSON->new();
$json->utf8(0);
my $resp = $json->deco
hift;
my $content = $self->_response_decoded_content($request);
my $json = JSON->new();
$json->utf8(0);
my $resp = $json->decode($content);
return $resp->{'copyright'};
}
1;