1 package Net::GlobalPOPs::MediaServicesAPI;
8 use Net::HTTPS::Any qw( 0.10 https_post );
12 Net::GlobalPOPs::MediaServicesAPI - Interface to GlobalPOPs Media Services API
16 our $VERSION = '0.02';
17 our $URL = 'https://www.loginto.us/VOIP/api.pl';
18 #could be parsed from URL, if it mattered...
19 our $HOST = 'www.loginto.us';
20 our $PATH = '/VOIP/api.pl';
27 use Net::GlobalPOPs::MediaServicesAPI;
29 my $handle = Net::GlobalPOPs::MediaServicesAPI->new(
31 'password' => 'beast',
51 =head2 new HASHREF | OPTION, VALUE ...
53 Creates a new Net::GlobalPOPs::MediaServicesAPI object. Options may be passed
54 as a hash reference or a flat list of names and values.
58 =item login (required)
60 =item password (required)
62 =item login (required)
68 # If there is an error,
69 #returns false and sets an error string which may be queried with the I<errstr>
74 my $class = ref($proto) || $proto;
75 my $self = ref($_[0]) ? shift : { @_ };
87 unless ref($class) && $class->isa('Net::GlobalPOPs::MediaServicesAPI');
93 sub DESTROY { }; # no-op
97 my $opts = ref($_[0]) ? shift : { @_ };
99 $AUTOLOAD =~ /(^|::)(\w+)$/ or die "unparsable AUTOLOAD: $AUTOLOAD";
103 my $w = new XML::Writer(OUTPUT => \$output, DATA_MODE => 1, DATA_INDENT => 3);
105 $w->xmlDecl('ISO-8859-1');
106 $w->doctype('request', undef, $URL);
108 $w->startTag('request', 'id' => ''); #XXX request ID???
109 $w->startTag('header');
110 $w->startTag('sender');
112 if ( $self->{'sessionid'} ) {
114 #$w->dataElement( 'login' => '' );
115 #$w->dataElement( 'password' => '' );
116 $w->dataElement( 'sessionid' => $self->{'sessionid'} );
120 $w->dataElement( 'login' => $self->{'login'} );
121 $w->dataElement( 'password' => $self->{'password'} );
122 #$w->dataElement( 'sessionid' => '' );
126 $w->endTag('sender');
127 $w->endTag('header');
129 $w->startTag('body');
131 $w->dataElement( 'requesttype' => $function );
134 $w->startTag('item');
135 foreach my $opt ( keys %$opts ) {
136 $w->dataElement( $opt => $opts->{$opt} );
143 $w->endTag('request');
145 #$output =~ s/\n+/\n/g;
147 warn "XML Request for $function function:\n$output"
150 my( $page, $response, %reply_headers ) = https_post(
153 'args' => { 'apidata' => $output, },
154 #'content' => $output,
155 #'Content-Type' => 'text/plain',
156 #'Content-Type' => 'text/xml',
157 #'Content-Type' => 'application/xml',
159 'debug' => $self->{'debug'},
162 unless ( $response =~ /^200/i ) {
163 $self->{'errstr'} = $response;
167 warn "XML Response for $function function:\n: $page"
170 my $hashref = XMLin( $page );
172 warn "Parsed response for $function funtion:\n". Dumper($hashref)
175 my $return = $hashref->{'body'};
177 warn "Returning data:\n". Dumper($return)
186 Ivan Kohler, C<< <ivan-net-globalpops at freeside.biz> >>
190 Please report any bugs or feature requests to C<bug-net-globalpops-mediaservicesapi at rt.cpan.org>, or through
191 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-GlobalPOPs-MediaServicesAPI>. I will be notified, and then you'll
192 automatically be notified of progress on your bug as I make changes.
199 You can find documentation for this module with the perldoc command.
201 perldoc Net::GlobalPOPs::MediaServicesAPI
204 You can also look for information at:
208 =item * RT: CPAN's request tracker
210 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-GlobalPOPs-MediaServicesAPI>
212 =item * AnnoCPAN: Annotated CPAN documentation
214 L<http://annocpan.org/dist/Net-GlobalPOPs-MediaServicesAPI>
218 L<http://cpanratings.perl.org/d/Net-GlobalPOPs-MediaServicesAPI>
222 L<http://search.cpan.org/dist/Net-GlobalPOPs-MediaServicesAPI>
227 =head1 ACKNOWLEDGEMENTS
230 =head1 COPYRIGHT & LICENSE
232 Copyright 2008 Freeside Internet Services, Inc. (http://freeside.biz/)
234 This program is free software; you can redistribute it and/or modify it
235 under the same terms as Perl itself.
240 Open-source billing, trouble ticketing and automation for VoIP providers:
242 http://freeside.biz/freeside/
246 1; # End of Net::GlobalPOPs::MediaServicesAPI