;
use Pod::POM ();
use File::Path ();
use Storable (); # finally
use Fcntl ();
use JSON::XS qw(encode_json decode_json);
use Guard qw(guard);
=item shorten $string[, $maxlength]
=cut
sub shorten($;
line =~ s/\s+$//;
utf8::decode $line;
if ($line =~ /^\x{e877}json_msg (.*)$/s) {
$cb->(JSON::XS->new->allow_nonref->decode ($1));
} else {
::message
);
}
}
});
}
sub background_msg {
my ($msg) = @_;
$msg = "\x{e877}json_msg " . JSON::XS->new->allow_nonref->encode ($msg);
$msg =~ s/\n//g;
utf8::encode $msg;
print
ose>, L<HTML::TreeBuilder>, L<WWW::Mechanize>, L<Params::Validate>
L<XML::FeedPP>, L<DateTime>, L<JSON>, L<URI::Escape>, L<MIME::Types>,
L<File::MMagic>
=head1 INCOMPATIBILITIES
None reported.
=hea
se Bot::BasicBot::Pluggable::Module::Notes::Store::SQLite;
use File::Spec::Functions;
use JSON ();
my $store = Bot::BasicBot::Pluggable::Module::Notes::Store::SQLite
->new( "/home/ca
;
return [ 200, [ 'Content-type' => $type ], [ $file_content ] ];
}
sub notes_json {
my ($self, %params) = @_;
# my @checkedparams{ qw(date time channel name notes)
$rows,
};
return [ 200, [ 'Content-type' => 'application/json' ], [ JSON::encode_json($notes) ] ];
}
dispatch {
sub (/) {
return $self->static
kage Net::Google::Code::Role::Predefined;
use Any::Moose 'Role';
use Params::Validate ':all';
use JSON;
with 'Net::Google::Code::Role::Fetchable';
has 'predefined_status' => (
isa => 'HashRef',
ut luck :(
$mech->update_html(<<"EOF");
<form action="${base_url}feeds/${last_name}OptionsJSON"
method="POST" >
<input type="text" name="token" value="$token" />
<input type="submit" value="su
er => 1 );
die "failed to post to OptionsJSON page" unless $mech->success;
my $js = $mech->content;
my $object = from_json $js;
return unless $object;
$se
s/jquery.js
# to get the /path/to/htdocs/js/jquery.js
# $ GET http//localhost/js/dynamic-json.js
# to get the your application response
Will you want to set config from yaml?
my $mw
s/jquery.js
# to get the /path/to/htdocs/js/jquery.js
# $ GET http//localhost/js/dynamic-json.js
# to get the your application response
Do you want 404 handle has backend application?
N::Testers::Common::Utils 0.001
=head2 Support Modules
Optional but improve performance
=head3 JSON::XS 2.00
=head1 PENDING INCLUSION:
Metabase::Web 0.003 # not yet on CPAN
=head1 AUTHOR
Da
cut
use Carp;
use LWP::UserAgent;
use JSON;
my $KEEP_ALIVE_CACHESIZE = 10;
my $API_VERSION = '1.2.1';
my $ENDPOINT_BASE = 'api.smugmug.com/services/api/json/1.2.1/';
my $ERROR_CODE = {
MISSING_
>agent($agent);
$ua->timeout(30);
$ua->env_proxy;
my $json = JSON->new();
my $self = bless {
ua => $ua,
json => $json,
retry => $retry,
agent => $agent,
sm_
=> $params->{SessionID},
'X-Smug-Version' => $API_VERSION,
'X-Smug-ResponseType' => 'JSON',
'X-Smug-FileName' => $params->{FileName},
);
my @optional_params =
qw/AlbumID Image
cial::Client::Protocol::REST->new(
formatter => Net::OpenSocial::CLient::Formatter::JSON->new,
request_builder => Net::OpenSocial::Client::HTTPRequestBuilder::OAuth->new(...),
ooseX::AttributeHelpers;
use DateTime;
use DateTime::Format::ISO8601;
with Storage('format' => 'JSON', 'io' => 'File');
has 'id' => ( is => 'rw', isa => 'Int' );
has 'action' => ( is => 'rw', isa
nt->feed->publish_user_action(
template_bundle_id => 'id',
template_data => 'JSON',
body_general => 'markup',
target_ids => [@array_of_ids],
);
template_bundle(
one_line_story_templates => 'JSON',
short_story_templates => 'JSON',
full_story_template => 'JSON',
);
The formats for C<one_line_story_templates>
e => 'markup',
title_data => 'JSON',
body_template => 'markup',
body_general => 'markup',
body_data => 'JSON',
image_1 => 'image url',
ocial::Client::Protocol::RPC->new(
formatter => Net::OpenSocial::CLient::Formatter::JSON->new,
request_builder => Net::OpenSocial::Client::HTTPRequestBuilder::OAuth->new(...),
s = @_;
if (ref($args{'action_links'}) eq 'ARRAY') {
eval q{use JSON::Any};
croak "Unable to load JSON module to encode 'action_links':$@\n" if $@;
$args{'action_links'} =
k API.
$client->stream->publish(
message => $message,
attachment => $json,
action_links => [@links],
);
=item remove( %params )
The stream.remove method of t
$id )
The fbml.getCustomTags method of the Facebook API.
=item register_custom_tags( tags => [@json_tags] )
The fbml.registerCustomTags method of the Facebook API.
=item set_ref_handle( handle =
is the only
parameter required.
$client->fbml->upload_native_strings(
native_strings => 'JSON'
);
The format for C<native_strings> is described on the developers wiki:
http://wiki.developer
$json,
data => $RAW_DATA,
);
=item edit( %params )
The events.edit method of the Facebook API:
$response = $client->events->edit(
eid => $eid,
event_info => $json,
ent::Formatter::JSON;
use Net::OpenSocial::Client::Type::Protocol qw(REST RPC);
use Net::OpenSocial::Client::Type::Auth qw(OAUTH ST);
use Net::OpenSocial::Client::Type::Format qw(JSON XML ATOM);
wit
lt => OAUTH,
);
has 'format_type' => (
is => 'ro',
isa => 'Str',
default => JSON,
);
has 'consumer_key' => (
is => 'ro',
isa => 'Str',
);
has 'consumer_secret' => (
ld_formatter {
my $self = shift;
if ( $self->format_type eq JSON ) {
return Net::OpenSocial::Client::Formatter::JSON->new;
}
# XXX: not supported yet
#elsif ( $self->forma
ype::Format;
use strict;
use warnings;
use base 'Exporter';
our @EXPORT_OK = qw(JSON XML ATOM);
use constant JSON => 0;
use constant XML => 1;
use constant ATOM => 2;
1;
=head1 NAME
Net::OpenS
ants for format-type
=head1 SYNOPSIS
use Net::OpenSocial::Client::Type::Auth qw(JSON XML ATOM);
say JSON;
say XML;
say ATOM;
=head1 DESCRIPTION
Constants for format-type.
But curre
support XML and ATOM format.
=head1 VALUES
=over 4
=item JSON
use JSON encoder/decoder.
See L<Net::OpenSocial::Client::Formatter::JSON> for more detail.
=item XML
use XML encoder/decoder.
Now n
lient->profile->set_info(
title => 'title',
type => '1|5',
info_fields => 'JSON',
uid => 'user_id',
);
The format for C<info_fields> is described on the developer wik
ns(
field => 'field_title',
options => 'JSON',
);
The format for C<options> is described on the developer wiki:
http://wiki.developers.fa
e warnings;
use strict;
use version; our $VERSION = qv('0.0.1');
use LWP::UserAgent;
use JSON qw( from_json );
use WWW::Freelancer::Project;
use WWW::Freelancer::User;
my $user_agent = LWP::UserAge
my $content = $user_agent->get("http://api.freelancer.com/Project/$id.json")
->decoded_content();
return bless from_json($content)->{'project'}, 'WWW::Freelancer::Project';
}
sub get_user
agent->get(
"http://api.freelancer.com/User/Properties.json$query_string")
->decoded_content();
return bless from_json($content)->{'profile'}, 'WWW::Freelancer::User';
}
sub search
et::OpenSocial::Client::Type::Auth qw(OAUTH ST);
use Net::OpenSocial::Client::Type::Format qw(JSON XML);
use Net::OpenSocial::Client::Type::Protocol qw(REST RPC);
my $client = Net::OpenSo
ew(
container => $container,
auty_type => OAUTH,
format_type => JSON,
protocol_type => REST,
);
=head3 container
First, you have to prepare L<Net::OpenS
=> q{foobarbuz},
...
);
=head3 format_type
Now it only supports JSON format, so, it sets JSON by default.
=head3 protocol_type
REST or RPC.
REST is set by default.
Make sure th
the Facebook API.
$result = $client->Admin->set_app_properties(
properties => encode_json {
application_name => 'testapp',
callback_url => 'http://example.com/testapp/'
method of the Facebook API.
$result = $client->Admin->set_restriction_info(
encode_json { age => '21+', location => 'us' }
);
=item ban_users( %params )
The Admin.banUsers method