1 package Net::GlobalPOPs::MediaServicesAPI;
8 use Net::HTTPS::Any qw(https_post);
12 Net::GlobalPOPs::MediaServicesAPI - Interface to GlobalPOPs Media Services API
20 our $VERSION = '0.01';
21 our $URL = 'https://www.loginto.us/VOIP/api.pl';
22 #could be parsed from URL, if it mattered...
23 our $HOST = 'www.loginto.us';
24 our $PATH = '/VOIP/api.pl';
31 use Net::GlobalPOPs::MediaServicesAPI;
33 my $handle = Net::GlobalPOPs::MediaServicesAPI->new(
35 'password' => 'beast',
55 =head2 new HASHREF | OPTION, VALUE ...
57 Creates a new Net::GlobalPOPs::MediaServicesAPI object. Options may be passed
58 as a hash reference or a flat list of names and values.
62 =item login (required)
64 =item password (required)
66 =item login (required)
72 # If there is an error,
73 #returns false and sets an error string which may be queried with the I<errstr>
78 my $class = ref($proto) || $proto;
79 my $self = ref($_[0]) ? shift : { @_ };
91 unless ref($class) && $class->isa('Net::GlobalPOPs::MediaServicesAPI');
97 sub DESTROY { }; # no-op
101 my $opts = ref($_[0]) ? shift : { @_ };
103 $AUTOLOAD =~ /(^|::)(\w+)$/ or die "unparsable AUTOLOAD: $AUTOLOAD";
107 my $w = new XML::Writer(OUTPUT => \$output, DATA_MODE => 1, DATA_INDENT => 3);
109 $w->xmlDecl('ISO-8859-1');
110 $w->doctype('request', undef, $URL);
112 $w->startTag('request', 'id' => ''); #XXX request ID???
113 $w->startTag('header');
114 $w->startTag('sender');
116 if ( $self->{'sessionid'} ) {
118 #$w->dataElement( 'login' => '' );
119 #$w->dataElement( 'password' => '' );
120 $w->dataElement( 'sessionid' => $self->{'sessionid'} );
124 $w->dataElement( 'login' => $self->{'login'} );
125 $w->dataElement( 'password' => $self->{'password'} );
126 #$w->dataElement( 'sessionid' => '' );
130 $w->endTag('sender');
131 $w->endTag('header');
133 $w->startTag('body');
135 $w->dataElement( 'requesttype' => $function );
137 foreach my $opt ( keys %$opts ) {
139 $w->dataElement( $opt => $opts->{$opt} );
145 $w->endTag('request');
147 #$output =~ s/\n+/\n/g;
149 warn "XML Request for $function function:\n$output"
152 my( $page, $response, %reply_headers ) = https_post(
155 'args' => { 'apidata' => $output, },
156 #'content' => $output,
157 #'Content-Type' => 'text/plain',
158 #'Content-Type' => 'text/xml',
159 #'Content-Type' => 'application/xml',
161 'debug' => $self->{'debug'},
164 unless ( $response =~ /^HTTP\/[\d\.]+\s+200/i ) {
165 $self->{'errstr'} = $response;
169 warn "XML Response for $function function:\n: $page"
172 my $hashref = XMLin( $page );
174 warn "Parsed response for $function funtion:\n". Dumper($hashref)
177 my $return = $hashref->{'body'};
179 warn "Returning data:\n". Dumper($return)
188 Ivan Kohler, C<< <ivan-net-globalpops at freeside.biz> >>
192 Please report any bugs or feature requests to C<bug-net-globalpops-mediaservicesapi at rt.cpan.org>, or through
193 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-GlobalPOPs-MediaServicesAPI>. I will be notified, and then you'll
194 automatically be notified of progress on your bug as I make changes.
201 You can find documentation for this module with the perldoc command.
203 perldoc Net::GlobalPOPs::MediaServicesAPI
206 You can also look for information at:
210 =item * RT: CPAN's request tracker
212 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-GlobalPOPs-MediaServicesAPI>
214 =item * AnnoCPAN: Annotated CPAN documentation
216 L<http://annocpan.org/dist/Net-GlobalPOPs-MediaServicesAPI>
220 L<http://cpanratings.perl.org/d/Net-GlobalPOPs-MediaServicesAPI>
224 L<http://search.cpan.org/dist/Net-GlobalPOPs-MediaServicesAPI>
229 =head1 ACKNOWLEDGEMENTS
232 =head1 COPYRIGHT & LICENSE
234 Copyright 2008 Freeside Internet Services, Inc. (http://freeside.biz/)
236 This program is free software; you can redistribute it and/or modify it
237 under the same terms as Perl itself.
242 Open-source billing, trouble ticketing and automation for VoIP providers:
244 http://freeside.biz/freeside/
248 1; # End of Net::GlobalPOPs::MediaServicesAPI