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' => '1'); #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/\n/g;
149 warn "XML Request for $function function:\n$output"
152 my( $page, $response, %reply_headers ) = https_post(
155 'content' => $output,
156 'Content-Type' => 'text/plain',
158 'debug' => $self->{'debug'},
161 unless ( $response =~ /^HTTP\/[\d\.]+\s+200/i ) {
162 $self->{'errstr'} = $response;
166 warn "XML Response for $function function:\n: $page"
169 my $hashref = XMLin $page;
171 warn "Parsed response for $function funtion:\n: ". Dumper($hashref)
180 Ivan Kohler, C<< <ivan-net-globalpops at freeside.biz> >>
184 Please report any bugs or feature requests to C<bug-net-globalpops-mediaservicesapi at rt.cpan.org>, or through
185 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-GlobalPOPs-MediaServicesAPI>. I will be notified, and then you'll
186 automatically be notified of progress on your bug as I make changes.
193 You can find documentation for this module with the perldoc command.
195 perldoc Net::GlobalPOPs::MediaServicesAPI
198 You can also look for information at:
202 =item * RT: CPAN's request tracker
204 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-GlobalPOPs-MediaServicesAPI>
206 =item * AnnoCPAN: Annotated CPAN documentation
208 L<http://annocpan.org/dist/Net-GlobalPOPs-MediaServicesAPI>
212 L<http://cpanratings.perl.org/d/Net-GlobalPOPs-MediaServicesAPI>
216 L<http://search.cpan.org/dist/Net-GlobalPOPs-MediaServicesAPI>
221 =head1 ACKNOWLEDGEMENTS
224 =head1 COPYRIGHT & LICENSE
226 Copyright 2008 Freeside Internet Services, Inc. (http://freeside.biz/)
228 This program is free software; you can redistribute it and/or modify it
229 under the same terms as Perl itself.
234 Open-source billing, trouble ticketing and automation for VoIP providers:
236 http://freeside.biz/freeside/
240 1; # End of Net::GlobalPOPs::MediaServicesAPI