Pedro Figueiredo > WWW-Shorten-PunyURL-0.03 > WWW::Shorten::PunyURL

Download:
WWW-Shorten-PunyURL-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.03   Source  

NAME ^

WWW::Shorten::PunyURL - An interface to SAPO's URL shortening service

VERSION ^

Version 0.03

SYNOPSIS ^

PunyURL is a URL shortening service provided by SAPO (http://sapo.pt/). Given a URL, it replies with two versions of the short URL, one using Unicode and RFC3492-compliant (Punycode) and an ASCII-equivalent (lowercase).

You can also provide the shortened URL and get back the original one.

    use WWW::Shorten::PunyURL;

    my $punyurl = WWW::Shorten::PunyURL->new( url => $long );
    $punyurl->shorten;
    
    # or
    
    my $punyurl = WWW::Shorten::PunyURL->new( url => $short );
    $punyurl->long;

Optionally, you can give the constructor a timeout value (which defaults to 10 seconds):

    my $punyurl = WWW::Shorten::PunyURL->new(
        url     => $long,
        timeout => 5
    );

TODO ^

* Write conditional network tests

* Report/fix bug in Regexp::Common::URI (doesn't handle Unicode) UNTIL THIS IS FIXED, REQUESTING THE URL CORRESPONDING TO A PUNYCODE SHORTENED ONE WILL BREAK HORRIBLY AND PROBABLY DESTROY THE WORLD. USE THE ASCII SHORT VERSION FOR NOW.

CONSTANTS ^

ENDPOINT

The service endpoint for PunyURL

EXPORTS ^

makeashorterlink

This function will return the PunyURL corresponding to the original URL.

makealongerlink

This function does the reverse, finding the long URL corresponding to a PunyURL.

FUNCTIONS ^

new

Create a new WWW::Shorten::PunyURL object. Takes a string (containing a URL) as the argument (may also take an optional timeout, see SYNOPSIS):

    my $punyurl = WWW::Shorten::PunyURL->new( $url );

shorten

Give it a long url and you will get two shortened URLs, one using Unicode and its equivalent in lowercase ASCII. Returns undef on failure.

    my $result = $punyurl->shorten;
    
    if ( $result ) {
        print $punyurl->url, "is now:\n";
        print "\t", $punyurl->puny, "\n";
        print "\t", $punyurl->ascii, "\n";
        print "\t", $punyurl->preview, "\n";
    } else {
        print STDERR "Error:\n";
        print STDERR $punyurl->errstr, "(", $punyurl->error, "\n";
    }

long

Given a short URL (that you previously got through shorten() or any other means), returns the original URL, or undef in case of failure.

    $punyurl->long;

AUTHOR ^

Pedro Figueiredo, <me at pedrofigueiredo.org>

BUGS ^

Please report any bugs or feature requests to bug-www-shorten-punyurl at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Shorten-PunyURL. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc WWW::Shorten::PunyURL

You can also look for information at:

ACKNOWLEDGEMENTS ^

COPYRIGHT & LICENSE ^

Copyright 2009 Pedro Figueiredo, all rights reserved.

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