1 package Net::VoIP_Innovations;
8 use Net::HTTPS::Any qw( 0.10 https_post );
12 Net::VoIP_Innovations - Interface to VoIP_Innovations API
16 our $VERSION = '2.00';
17 our $URL = 'https://www.loginto.us/VOIP/api2.pl';
18 #could be parsed from URL, if it mattered...
19 our $HOST = 'www.loginto.us';
20 our $PATH = '/VOIP/api2.pl';
21 our $PORT = 443; #to allow testing to override
28 use Net::VoIP_Innovations;
30 my $handle = Net::VoIP_Innovations->new(
32 'password' => 'beast',
52 =head2 new HASHREF | OPTION, VALUE ...
54 Creates a new Net::VoIP_Innovations object. Options may be passed
55 as a hash reference or a flat list of names and values.
59 =item login (required)
61 =item password (required)
63 =item login (required)
69 # If there is an error,
70 #returns false and sets an error string which may be queried with the I<errstr>
75 my $class = ref($proto) || $proto;
76 my $self = ref($_[0]) ? shift : { @_ };
77 $self->{'debug'} ||= 0;
89 unless ref($class) && $class->isa('Net::VoIP_Innovations');
95 sub DESTROY { }; # no-op
99 my $opts = ref($_[0]) ? shift : { @_ };
101 $AUTOLOAD =~ /(^|::)(\w+)$/ or die "unparsable AUTOLOAD: $AUTOLOAD";
105 my $w = new XML::Writer(OUTPUT => \$output, DATA_MODE => 1, DATA_INDENT => 3);
107 $w->xmlDecl('ISO-8859-1');
108 $w->doctype('request', undef, $URL);
110 $w->startTag('request', 'id' => ''); #XXX request ID???
111 $w->startTag('header');
112 $w->startTag('sender');
114 if ( $self->{'sessionid'} ) {
116 #$w->dataElement( 'login' => '' );
117 #$w->dataElement( 'password' => '' );
118 $w->dataElement( 'sessionid' => $self->{'sessionid'} );
122 $w->dataElement( 'login' => $self->{'login'} );
123 $w->dataElement( 'password' => $self->{'password'} );
124 #$w->dataElement( 'sessionid' => '' );
128 $w->endTag('sender');
129 $w->endTag('header');
131 $w->startTag('body');
133 $w->dataElement( 'requesttype' => $function );
136 $w->startTag('item');
137 foreach my $opt ( keys %$opts ) {
138 $w->dataElement( $opt => $opts->{$opt} );
145 $w->endTag('request');
147 #$output =~ s/\n+/\n/g;
149 warn "XML Request for $function function:\n$output"
150 if $self->{'debug'} > 1;
152 my( $page, $response, %reply_headers ) = https_post(
155 'path' => ($PATH||443),
156 'args' => { 'apidata' => $output, },
157 #'content' => $output,
158 #'Content-Type' => 'text/plain',
159 #'Content-Type' => 'text/xml',
160 'Content-Type' => 'application/xml',
162 'debug' => ( $self->{'debug'} > 1 ? 1 : 0 ),
165 unless ( $response =~ /^200/i ) {
166 $self->{'errstr'} = $response;
170 warn "XML Response for $function function:\n: $page"
171 if $self->{'debug'} > 1;
173 my $hashref = XMLin( $page );
175 warn "Parsed response for $function funtion:\n". Dumper($hashref)
176 if $self->{'debug'} > 1;
178 my $return = $hashref->{'body'};
180 warn "Returning data:\n". Dumper($return)
181 if $self->{'debug'} > 1;
189 Ivan Kohler, C<< <ivan-net-voipinnovations at freeside.biz> >>
193 Please report any bugs or feature requests to C<bug-net-voip_innovations at rt.cpan.org>, or through
194 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-VoIP_Innovations>. I will be notified, and then you'll
195 automatically be notified of progress on your bug as I make changes.
202 You can find documentation for this module with the perldoc command.
204 perldoc Net::VoIP_Innovations
207 You can also look for information at:
211 =item * RT: CPAN's request tracker
213 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-VoIP_Innovations>
215 =item * AnnoCPAN: Annotated CPAN documentation
217 L<http://annocpan.org/dist/Net-VoIP_Innovations>
221 L<http://cpanratings.perl.org/d/Net-VoIP_Innovations>
225 L<http://search.cpan.org/dist/Net-VoIP_Innovations>
230 =head1 ACKNOWLEDGEMENTS
233 =head1 COPYRIGHT & LICENSE
235 Copyright 2008-2012 Freeside Internet Services, Inc. (http://freeside.biz/)
237 This program is free software; you can redistribute it and/or modify it
238 under the same terms as Perl itself.
243 Need a complete, open-source back-office and customer self-service solution?
244 The Freeside software includes support for VoIP Innovations integration, CDR
245 rating, invoicing, credit card and electronic check processing, integrated
246 trouble ticketing, and customer signup and self-service web interfaces.
248 http://freeside.biz/freeside/
252 1; # End of Net::VoIP_Innovations