diff options
Diffstat (limited to 'lib/Net/GlobalPOPs')
-rw-r--r-- | lib/Net/GlobalPOPs/MediaServicesAPI.pm | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/Net/GlobalPOPs/MediaServicesAPI.pm b/lib/Net/GlobalPOPs/MediaServicesAPI.pm index 88ee0d2..c28f8ea 100644 --- a/lib/Net/GlobalPOPs/MediaServicesAPI.pm +++ b/lib/Net/GlobalPOPs/MediaServicesAPI.pm @@ -13,11 +13,12 @@ Net::GlobalPOPs::MediaServicesAPI - Interface to GlobalPOPs Media Services API =cut -our $VERSION = '0.02'; +our $VERSION = '0.03'; our $URL = 'https://www.loginto.us/VOIP/api.pl'; #could be parsed from URL, if it mattered... our $HOST = 'www.loginto.us'; our $PATH = '/VOIP/api.pl'; +our $PORT = 443; #to allow testing to override our $AUTOLOAD; our $errstr = ''; @@ -73,6 +74,7 @@ sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = ref($_[0]) ? shift : { @_ }; + $self->{'debug'} ||= 0; bless($self, $class); } @@ -145,18 +147,19 @@ sub AUTOLOAD { #$output =~ s/\n+/\n/g; warn "XML Request for $function function:\n$output" - if $self->{'debug'}; + if $self->{'debug'} > 1; my( $page, $response, %reply_headers ) = https_post( 'host' => $HOST, - 'path' => $PATH, + 'port' => $PORT, + 'path' => ($PATH||443), 'args' => { 'apidata' => $output, }, #'content' => $output, #'Content-Type' => 'text/plain', #'Content-Type' => 'text/xml', #'Content-Type' => 'application/xml', #'headers' => {}, - 'debug' => $self->{'debug'}, + 'debug' => ( $self->{'debug'} > 1 ? 1 : 0 ), ); unless ( $response =~ /^200/i ) { @@ -165,17 +168,17 @@ sub AUTOLOAD { } warn "XML Response for $function function:\n: $page" - if $self->{'debug'}; + if $self->{'debug'} > 1; my $hashref = XMLin( $page ); warn "Parsed response for $function funtion:\n". Dumper($hashref) - if $self->{'debug'}; + if $self->{'debug'} > 1; my $return = $hashref->{'body'}; warn "Returning data:\n". Dumper($return) - if $self->{'debug'}; + if $self->{'debug'} > 1; $return; |