Created
November 16, 2011 23:04
-
-
Save kimarx/1371799 to your computer and use it in GitHub Desktop.
You'll say "You use Moose for this small module as if taking a sledgehammer to crack a nut!" :-) "
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package RealURL; | |
use Moose; | |
has 'shorturi' => ( is => 'rw', ); | |
__PACKAGE__->meta->make_immutable(); | |
no Moose; | |
use LWP::Simple; | |
use XML::Simple; | |
sub expand_uri { | |
my $self = shift; | |
my $uri_for_api = $self->shorturi; | |
$uri_for_api = 'http://realurl.org/api/v1/getrealurl.php?url=' . $uri_for_api; | |
my $xml_response = get( $uri_for_api ); | |
my $xs = XML::Simple->new(); | |
my $ref = $xs->XMLin( $xml_response ); | |
my $original_uri = $ref->{url}->{real}; | |
return $original_uri; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment