#!/usr/bin/perl
use strict;
use JSON::XS;
use Web::Scraper;
use URI;
sub extract_url { (m!(http://\S*)!)[0] }
my $uri = URI->new( shift || "http://www.oembed.com/" );
my $scraper = scraper {
pr
(text(), 'Endpoint')]", api => [ 'TEXT', \&extract_url ];
};
result 'providers';
};
my @providers = grep { defined $_->{url} } @{ $scraper->scrape($uri) };
print encode_json(\@providers);
_res, matched_uri => $uri );
my $data;
if ($http_res->content_type =~ /json/) {
$data = $res->parse_json($http_res->content);
} elsif ($http_res->content_type =~ /xml/) {
ata = $res->parse_xml($http_res->content);
} else {
croak "Content-Type is not either JSON or XML: " . $http_res->content_type;
}
for my $key (keys %$data) {
if ($res->can
= $data->{$key};
}
}
$res;
}
sub parse_json {
my($self, $json) = @_;
require JSON::XS;
JSON::XS->new->decode($json);
}
sub parse_xml {
my($self, $xml) = @_;
requ
t;
use 5.8.1;
our $VERSION = '0.04';
use Any::Moose;
has 'format' => (is => 'rw', default => 'json');
has 'discovery' => (is => 'rw');
has 'providers' => (is => 'rw', isa => 'ArrayRef', default =>
bed consumer
=head1 SYNOPSIS
use Web::oEmbed;
my $consumer = Web::oEmbed->new({ format => 'json' });
$consumer->register_provider({
url => 'http://*.flickr.com/*',
api => 'http:
=over 4
=item new
$consumer = Web::oEmbed->new;
$consumer = Web::oEmbed->new({ format => 'json' });
Creates a new Web::oEmbed instance. You can specify the default format
that will be used wh