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
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
e Carp qw/croak/;
use Date::Format;
use DateTime::Format::Natural;
use HTTP::Request::Common;
use JSON::XS;
use XML::Simple;
use YAML qw/freeze/;
sub make_request {
my %attr = ref $_[0] eq 'HASH
XMLout $obj, RootName=>'vehicleinformation', GroupTags => { stops => 'stop' };
/json/i and return JSON::XS->new->ascii->pretty->allow_nonref->encode($obj);
/yaml/i and return freeze $
transformed into other data formats
=over 4
=item *
xml
=item *
XML
=item *
YAML
=item *
JSON
=item *
perl (default)
=back
=head3 example of output when dataType = 'xml'
=head1 METHODS
ion => '1.6.0.3');
my($content) = $browser->content =~ /content":\s*"(.*?)"\s*}/;
$content = json_unescape($content);
debug "Content is '$content'";
$browser->update_html($content);
}
sub tr
ponse is a JSON data structure
return parse_video_info( $browser, $browser->content );
}
# The JSON video info hash has everything we need
sub parse_video_info {
my ( $browser, $json ) = @_;
debug "Video data: $json";
=begin
JSON structure:
{
"data": [
{
"tt": "0",
"ct": "f",
"cs": "2128",
"logo": "http:\/\/vimg8.yoqoo.com\/1100641F464A093EE7A01B01
( $json =~ /"seed":(\d+)/ );
die "Can't find the seed value in the video info JSON"
unless $shuffle_seed;
# Sometimes, the video has a HQ version in mp4 format
my ( $streams ) = ( $json =~
ostende', date => 'tomorrow afternoon'
# JSON station lookup of all stations matching qr/oost/
print irail station => qr/oost/, dataType => 'json'
# XML vehicle lookup
print irail ve
ould override some internals.
my $irail = new WWW::IRail::API( client => 'LWP', dataType => 'JSON' );
=head2 lookup_stations(I<key => 'value'> | I<{key => 'value'}>)
Method which takes a string
} );
my $json_string = $irail->lookup_stations(filter => qr/./, dataType => 'JSON');
=head1 FEATURES
=head2 Multiple output formats
The returned results can be in either XML, JSON or YAML form
ghtweight OAuth api for SinaWeibo
use strict;
use warnings;
use base 'Net::SinaWeibo::OAuth';
use JSON;
use constant {
SINA_SITE => 'http://api.t.sina.com.cn/',
SINA_REQUEST_TOKE
CCESS_TOKEN_URL => 'http://api.t.sina.com.cn/oauth/access_token',
SINA_FORMAT => 'json',
};
# SINA SDK API
our %SINA_API = (
public_timeline => {
uri => 'statuses/public_ti
i_error_code
Get last api error_code, which return by provider. If provider reponse is
not valid JSON message, it's just the http status code.
=head2 last_api_error_subcode
Get detail error code ab
use OAuth::Lite::AuthMethod qw(:all);
use List::MoreUtils qw(any);
use HTTP::Request::Common;
use JSON;
use OAuth::Lite::Util qw(normalize_params);
use constant {
SINA_SITE => 'http
authorize',
SINA_ACCESS_TOKEN_PATH => '/oauth/access_token',
SINA_FORMAT => 'json',
};
__PACKAGE__->mk_accessors(qw(
last_api
last_api_error
last_api_error_code
la
croak $content;
}
decode_json($content);
}
sub _api_error {
my ($self,$error,$http_code) = @_;
eval {
my $error = decode_json($error);
$self->last_api_error($e
e Carp qw/croak/;
use Date::Format;
use DateTime::Format::Natural;
use HTTP::Request::Common;
use JSON::XS;
use XML::Simple;
use YAML qw/freeze/;
sub make_request {
my %attr = ref $_[0] eq 'HASH
ns',KeepRoot => 0, GroupTags => { connections => 'connection', vias => 'via' };
/json/i and return JSON::XS->new->ascii->pretty->allow_nonref->encode($obj);
/yaml/i and return freeze $
transformed into other data formats
=over 4
=item *
xml
=item *
XML
=item *
YAML
=item *
JSON
=item *
perl (default)
=back
=head3 example of output when dataType = 'xml'
=head1 METHODS
e Carp qw/croak/;
use Date::Format;
use DateTime::Format::Natural;
use HTTP::Request::Common;
use JSON::XS;
use XML::Simple;
use YAML qw/freeze/;
sub make_request {
my %attr = ref $_[0] eq 'HASH
turn XMLout $obj, RootName=>'stations', GroupTags => { stations => 'station' };
/json/i and return JSON::XS->new->ascii->pretty->allow_nonref->encode($obj);
/yaml/i and return freeze $
he data unnested for easier access.
=over 4
=item *
xml
=item *
XML
=item *
YAML
=item *
JSON
=item *
perl (default)
=back
=head3 example of output when dataType = 'xml'
<stations>
I::Liveboard::VERSION = '0.003';
}
use strict;
use Carp qw/croak/;
use HTTP::Request::Common;
use JSON::XS;
use XML::Simple;
use YAML qw/freeze/;
sub make_request {
my %attr = ref $_[0] eq 'HASH'
'liveboard', GroupTags => { departures => 'departure', arrivals => 'arrival' };
/json/i and return JSON::XS->new->ascii->pretty->allow_nonref->encode($obj);
/yaml/i and return freeze $
transformed into other data formats
=over 4
=item *
xml
=item *
XML
=item *
YAML
=item *
JSON
=item *
perl (default)
=back
=head3 example of output when dataType = 'xml'
<liveboard s
hash_data EXTENSIONS get_user_config_dir get_win_codepage
is_program_on_path get_terminal_width json_unescape
convert_sami_subtitles_to_srt from_xml);
sub debug(@) {
# Remove some sensitive dat
per JSON parser, but want to avoid the dependency for now..
# (There is now one in FlashVideo::JSON, so consider that -- this is just here
# until we have a chance to fix things using it).
sub json_un
ostende', date => 'tomorrow afternoon'
# JSON station lookup of all stations matching qr/oost/
print irail station => qr/oost/, dataType => 'json'
# XML vehicle lookup
print irail ve
ta.
=head1 FEATURES
=head2 Multiple output formats
The returned results can be in either XML, JSON or YAML format. You can even
select between two flavours XML (xml, XML) to suit your taste. Ofcou
//www.wat.tv/interface/contentv2/$video_id");
my $title = json_unescape(($browser->content =~ /title":"(.*?)",/)[0]);
my $url = json_unescape(($browser->content =~ /files.*?url":"(.*?)",/)[0]);
ite::Youtube;
use strict;
use Encode;
use HTML::Entities;
use FlashVideo::Utils;
use FlashVideo::JSON;
use URI::Escape;
my @formats = (
{ id => 38, resolution => [4096, 2304] },
{ id => 37, reso
p method from page ($1)";
return $self->download_fmt_map($prefs, $browser, $title, {}, @{from_json $1});
}
my $video_id;
if ($browser->content =~ /(?:var pageVideoId =|(?:CFG_)?VIDEO_ID'?\s
\s*(\{.*?\});/ && (my $swf = from_json($1))) {
$swf_url = $swf->{url};
} elsif($browser->content =~ /src=\\['"]([^'"]+\.swf)/) {
$swf_url = json_unescape($1);
} else {
} else {
die "Unable to find download link";
}
# TODO - support subtitles. Available in JSON (urgh):
# http://www.ted.com/talks/subtitles/id/453/lang/eng
# The ID can be pulled out of
#!/usr/bin/perl
use Data::Dumper;
use JSON::XS;
use LWP::UserAgent;
###############################################################################
## Station Data Dumper - copyright (c) 2010 Tim Ess
# requote ident & non nums
my $json_string = $js; # js is munged to JSON now
# decode the json_strong
my $station_list = decode_json($json_string);
# map to a handy str
$browser, $embed_url) = @_;
my $metadata = { };
my ($video_id, $player_id);
# URL params, JSON, etc..
$video_id = ($browser->content =~ /(?:clip|video)Id["'\] ]*[:=]["' ]*(\d+)/i)[0];
$pl
package WebService::Etsy;
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Carp;
use WebService::Etsy::Response;
use IO::File;
use WebService::Etsy::Resource;
use base qw( Clas
s the Etsy API, as described at L<http://developer.etsy.com/>.
The API is RESTful, and returns JSON. This module abstracts this away to present a standard Perl object interface.
The API methods
. $resp->status_line );
return;
}
$self->log( $log_msg );
my $data = from_json( $resp->content );
my $detail = ( $data->{ params } && ref $data->{ params } eq "HASH" ) ?
ns::Plugin::HMI::Catalyst::View::TT - Catalyst TT View
=cut
use base 'Catalyst::View::TT';
use JSON;
__PACKAGE__->config({
PRE_PROCESS => 'bootstrap.tt',
WRAPPER => 'wrapper.tt',
TEMPLATE_
SCALAR_OPS->{printf} = sub { sprintf $_[1], $_[0] };
$Template::Stash::LIST_OPS->{to_json} = sub { return to_json(shift, { allow_barekey => 1, allow_singlequote => 1} ) };
=head1 AUTHOR
Mike Eldrid