|
NAMEWeb::oEmbed - oEmbed consumer SYNOPSIS use Web::oEmbed;
my $consumer = Web::oEmbed->new({ format => 'json' });
$consumer->register_provider({
url => 'http://*.flickr.com/*',
api => 'http://www.flickr.com/services/oembed/',
});
my $response = eval { $consumer->embed("http://www.flickr.com/photos/bulknews/2752124387/") };
if ($response) {
$response->matched_uri; # 'http://www.flickr.com/photos/bulknews/2752124387/'
$response->type; # 'photo'
$response->title; # title of the photo
$response->url; # JPEG URL
$response->width; # JPEG width
$response->height; # JPEG height
$response->provider_name; # Flickr
$response->provider_url; # http://www.flickr.com/
print $response->render; # handy shortcut to generate <img/> tag
}
DESCRIPTIONWeb::oEmbed is a module that implements oEmbed consumer. METHODS
METHODS in Web::oEmbed::Response
TODOCurrently if you register 100 providers, the embed method could potentially iterate through all of providers to run the regular expression, which doesn't sound good. I guess we could come up with some Trie-ish regexp solution that immediately returns the correspondent provider by compiling all regular expressions into one. Patches are welcome on this :) COPYRIGHTSix Apart, Ltd. <cpan@sixapart.com> AUTHORTatsuhiko Miyagawa <miyagawa@cpan.org> LICENSEThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO<http://www.oembed.com/>, JSON::XS, XML::LibXML::Simple
|