projects
/
Net-Vitelity.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Net::Vitelity improvements, RT4868
[Net-Vitelity.git]
/
lib
/
Net
/
Vitelity.pm
diff --git
a/lib/Net/Vitelity.pm
b/lib/Net/Vitelity.pm
index
d0ef45e
..
1259820
100644
(file)
--- a/
lib/Net/Vitelity.pm
+++ b/
lib/Net/Vitelity.pm
@@
-2,6
+2,7
@@
package Net::Vitelity;
use warnings;
use strict;
use warnings;
use strict;
+use LWP::UserAgent;
=head1 NAME
=head1 NAME
@@
-9,13
+10,15
@@
Net::Vitelity - Interface to Vitelity API
=head1 VERSION
=head1 VERSION
-Version 0.0
1
+Version 0.0
2
=cut
=cut
-our $VERSION = '0.0
1
';
+our $VERSION = '0.0
2
';
-our $URL = 'http://70.84.157.157/api.php';
+our $URL = 'http://64.74.178.105/api.php';
+
+our $AUTOLOAD;
=head1 SYNOPSIS
=head1 SYNOPSIS
@@
-31,7
+34,11
@@
our $URL = 'http://70.84.157.157/api.php';
=cut
sub new {
=cut
sub new {
- #XXX need a generic new
+ my ($class,%data) = @_;
+ die "missing user and/or password" unless defined $data{'login'} && defined $data{'pass'};
+ my $self = { 'login' => $data{'login'}, 'pass' => $data{'pass'} };
+ bless $self, $class;
+ return $self;
}
sub AUTOLOAD {
}
sub AUTOLOAD {
@@
-45,9
+52,9
@@
sub AUTOLOAD {
#XXX md5 encrypt pass
#XXX md5 encrypt pass
- $ua->post($URL, {
+
my $response =
$ua->post($URL, {
login => $self->{login},
login => $self->{login},
- pass => $self
=>{pass}
+ pass => $self
->{pass},
cmd => $cmd,
@_,
}
cmd => $cmd,
@_,
}
@@
-55,13
+62,10
@@
sub AUTOLOAD {
die $response->status_line unless $response->is_success;
die $response->status_line unless $response->is_success;
- #hmm
- #my $content = $response->content;
my $content = $response->decoded_content;
my $content = $response->decoded_content;
- #dear vitelity api: why does this make it easier to parse?
- $content =~ s/^x\[\[/;
- $content =~ s/\[\[x$/;
+ $content =~ /x\[\[(.*)\[\[x/s;
+ $content = $1;
wantarray ? split("\n", $content) : $content;
wantarray ? split("\n", $content) : $content;