NAME WebService::Embedly - Perl interface to the Embedly API VERSION Version 0.09 SYNOPSIS use WebService::Embedly; use Ouch qw(:traditional); my $embedly = WebService::Embedly->new({ api_key => 'get_your_key_at_embed.ly', maxwidth => 500 }); my $oembed_ref; my $e = try { $oembed_ref = $embedly->oembed('http://youtu.be/I8CSt7a7gWY'); }; if ( catch_all, $e) { warn("embedly api failed: ".$e); return; } #made it here, everything good. my $embed_html = $oembed_ref->{html}; DESCRIPTION The "WebService::Embedly" is a class implementing for querying the Embed.ly web service. Prior to using this module you should go to and sign up for an api_key. You can quickly try out the API by executing: ./sample/usage.pl --apikey you_api_key_from_embed.ly "WebService::Embedly" exposes three methods: oembed, preview, objectify. Each method has additional bits of metadata about the request URL. oembed method follows the oembed standard documented here Refer to to learn more about the data that is returned for preview and objectify Exception handling is used to expose failures. The Ouch module (:traditional) is used to handle try/catch blocks. See the Exception block below for all the possible catches. Example: my $e = try { $oembed_ref = $embedly->oembed('http://youtu.be/I8CSt7a7gWY'); }; if ( catch 500, $e) { #Server is down return; } if ( catch 401, $e) { #Your API key has used all its credits return; } elsif ( catch_all, $e) { #I hate the individual exception catching, lets get this over with it. return; } "WebService::Embedly" uses Mouse (lighter version of Moose) to handle its object management. CONSTRUCTOR You must pass the api_key into the constructor: my $embedly = WebService::Embedly->new({ api_key => 'get_your_key_at_embed.ly'}); "WebService::Embedly" uses LWP::UserAgent to handle its web requests. You have the option to pass in your own LWP object in case of special requirements, like a proxy server: my $ua = LWP::UserAgent->new(); $ua->proxy('http', 'http://proxy.sn.no:8001/'); my $embedly = WebService::Embedly->new({ api_key => 'get_your_key_at_embed.ly', ua => $ua }); Optional Params "WebService::Embedly" supports all optional parameters at the time of this writing . Refer to the embedly documentation for the complete description. In the majority of cases you only need to pay attention to the maxwidth param. It is highly recommended to specify maxwidth since the embed html could overflow the space you provide for it. maxwidth This is the maximum width of the embed in pixels. maxwidth is used for scaling down embeds so they fit into a certain width. If the container for an embed is 500px you should pass maxwidth=500 in the query parameters. maxheight This is the maximum height of the embed in pixels. width Will scale embeds type rich and video to the exact width that a developer specifies in pixels. format (default: json) The response format – Accepted values: (xml, json) callback Returns a (jsonp) response format. The callback is the name of the javascript function to execute. wmode Will append the wmode value to the flash object. Possible values include window, opaque and transparent. 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 script tag for saving and displaying later. Accepted values: (true, false) nostyle (default: false) There are a number of embeds that Embedly has created including Amazon.com, Foursquare, and Formspring. These all have