
WWW::Shorten::ptl - interface to shorten URLs with http://p.tl/

use WWW::Shorten::ptl ();
my $ptl = WWW::Shorten::ptl->new(apikey => $apikey);
my $res = $ptl->shorten($url);
my $shorturl = $res->{short_url} || die "failed to shorten $url";
my $longurl = $ptl->extract($shorturl);
or
use WWW::Shorten::ptl; my $shorturl = makeashorterlink($url, 'API-Key'); my $url = makealongerlink($shorturl);

WWW::Shorten::ptl provides interface to shorten URLs using http://p.tl/.

As p.tl requires API-Key for each access using its APIs, you should apply your API-Key for p.tl to shorten URLs with this module.
you can get API-Key for p.tl at http://p.tl/key_create.php.
API-Key is required only for shortening URLs. URL extraction service doesn't need API-Key

creates an instance of WWW::Shorten::ptl with given API-Key.
set or get API-Key for this instance.
shorten $url, and returns HASHREF with following keys.
status -- see 'RESULT STATUS' section long_url -- given (original) url short_url -- shortened url counter -- # of requests in a period. (currently, api request is limited to 1000 calls/day)
dies if no API-Key is set.
the 'status' should be one of below.
'ok' -- url is successfully shortened 'empty long url' -- input url is empty (should not occur when using this module) 'empty API key' -- API key is not specified (ditto.) 'API limit' -- request limit exceeded. 'invalid API key' -- given API key is invalid 'invalid long url'-- given url cannot be shortened (that url may be already shortened)
returns extracted $url. or undef when $url is not a form of p.tl.

As mentioned above, additional parameter API-Key is required for each shorten/expand functions.
returns shortened url. or undef when failed to shorten url.
returns expanded url for $url or undef when $url is not a form of p.tl

turugina <turugina {at} cpan.org>

WWW::Shorten http://p.tl/ http://dev.pixiv.net/archives/1156026.html

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.