![]() |
![]()
| ![]() |
![]()
NAMEWWW::Shorten::Yourls - Interface to shortening URLs using <http://yourls.org>VERSION$Revision: 0.06 $SYNOPSISWWW::Shorten::Yourls provides an easy interface for shortening URLs using http://yourls.org. In addition to shortening URLs, you can pull statistics that yourls.org gathers regarding each shortened WWW::Shorten::Yourls uses XML::Simple to convert the xml response for the meta info and click stats to create a hashref of the results.WWW::Shorten::Yourls provides two interfaces. The first is the common "makeashorterlink" and "makealongerlink" that WWW::Shorten provides. However, due to the way the yourls.org API works, additional arguments are required. The second provides a better way of retrieving additional information and statistics about a yourls.org URL. use WWW::Shorten::Yourls; my $url = "http://www.example.com"; my $tmp = makeashorterlink($url, 'MY_YOURLS_USERNAME', 'MY_YOURLS_PASSWORD'); my $tmp1 = makealongerlink($tmp, 'MY_YOURLS_USERNAME', 'MY_YOURLS_PASSWORD'); or use WWW::Shorten::Yourls; my $url = "http://www.example.com"; my $yourls = WWW::Shorten::Yourls->new(USER => "my_user_id", APIKEY => "my_api_key"); $yourls->shorten(URL => $url); print "shortened URL is $yourls->{url}\n"; $yourls->expand(URL => $yourls->{url}); print "expanded/original URL is $yourls->{longurl}\n"; FUNCTIONSnewCreate a new yourls.org object using your yourls.org user id and yourls.org api key.my $yourls = WWW::Shorten::Yourls->new(URL => "http://www.example.com/this_is_one_example.html", USER => "yourls_user_id", PASSWORD => "yourls_password"); makeashorterlinkThe function "makeashorterlink" will call the yourls.org API site passing it your long URL and will return the shorter yourls.org version.yourls.org requires the use of a user id and password to shorten links. makeashorterlink($url,$uid,$passwd,$base); makealongerlinkThe function "makealongerlink" does the reverse. "makealongerlink" will accept as an argument either the full yourls.org URL or just the yourls.org identifier. yourls.org requires the use of a user name and API Key when using the API.If anything goes wrong, then the function will return "undef". makealongerlink($url,$uid,$passwd,$base); THIS IS NOT WORKING RIGHT NOW AS YOURLS DOESN'T SUPPORT EXPANDING A URL. shortenShorten a URL using http://yourls.org. Calling the shorten method will return the shortened URL but will also store it in yourls.org object until the next call is made.my $url = "http://www.example.com"; my $shortstuff = $yourls->shorten(URL => $url); print "yurl is " . $yourls->{url} . "\n"; or print "yurl is $shortstuff\n"; expandExpands a shortened yourls.org URL to the original long URL.THIS ONLY WORKS WITH YOURLS 1.4+ Versions prior to Yourls 1.4 don't support expansion of shortened URLs. clicksGet click thru information for a shortened yourls.org URL. By default, the method will use the value that's stored in $yourls->{url}. To be sure you're getting info on the correct URL, it's a good idea to set this value before getting any info on it.THIS HAS NOT BEEN IMPLEMENTED YET AS YOURLS DOESN'T SUPPORT THIS FUNCTIONALITY. errorsTHIS IS NOT WORKING RIGHT NOW AS YOURLS DOESN'T SUPPORT ERROR RESPONSES FROM A URL.versionGets the module version numberFILES$HOME/.yourls or _yourls on Windows Systems.You may omit USER and PASSWORD in the constructor if you set them in the .yourls config file on separate lines using the syntax: USER=username PASSWORD=password AUTHORPankaj Jain, "<pjain at cpan.org>"BUGSPlease report any bugs or feature requests to "bug-www-shorten-yourls at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Shorten-Yourls>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.SUPPORTYou can find documentation for this module with the perldoc command.perldoc WWW::Shorten::Yourls You can also look for information at:
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. DISCLAIMER OF WARRANTYBECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SEE ALSOperl, WWW::Shorten, <http://yourls.org>.
|