Skip to content

Instantly share code, notes, and snippets.

@kimarx
Created November 16, 2011 23:04
Show Gist options
  • Save kimarx/1371799 to your computer and use it in GitHub Desktop.
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!" :-) "
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