7 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!C:\Perl\bin\perl
use strict;
use warnings;
require LWP::UserAgent;
require RPC::XML;
require RPC::XML::Client;
my $ua = LWP::UserAgent->new;
$ua->proxy(['http', 'https'], 'proxyname');
$ua->env_proxy;
my $cli = RPC::XML::Client->new('servername', $ua);
$cli->credentials('servername', 'username', 'password');
my $resp = $cli->send_request('system.listMethods');
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!C:\Perl\bin\perl
use strict;
use warnings;
require RPC::XML;
require RPC::XML::Client;
my $cli = RPC::XML::Client->new('servername');
my $ua = $cli->useragent;
$ua->proxy(['http', 'https'], 'proxyname');
$ua->env_proxy;
$cli->credentials('servername', 'username', 'password');
my $resp = $cli->send_request('system.listMethods');
QuoteThe following methods are available:
new (URI [, ARGS])
Creates a new client object that will route its requests to the URL provided. The constructor creates a HTTP::Request object and a LWP::UserAgent object, which are stored on the client object. When requests are made, these objects are ready to go, with the headers set appropriately. The return value of this method is a reference to the new object. The URI argument may be a string or an object from the URI class from CPAN.
Any additional arguments are treated as key-value pairs.Most are attached to the object itself without change. The following are recognized by new and treated specially:
...
useragent
This is similar to the parser argument above, and also expects an array reference to follow it. The contents are passed to the constructor of the LWP::UserAgent class when creating that component of the client object. See the manual page for LWP::UserAgent for supported values.
...
QuoteError: RPC::XML::Client::send_request: HTTP server error: Can't read entity body: Unknown error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl
use strict;
use warnings;
use Term::ReadKey;
require RPC::XML;
require RPC::XML::Client;
my @logindata;
print "username:\n";
$logindata[0] = ReadLine(0);
ReadMode('noecho');
print "password:\n";
$logindata[1] = ReadLine(0);
my $cli = RPC::XML::Client->new('https://servername/rpc/xmlrpc');
my $ua = $cli->useragent;
$ua->proxy(['https'], 'proxyserver');
my $resp = $cli->send_request('login', $logindata[0], $logindata[1]);
print ref $resp ? join(', ', @{$resp->value}) : "Error: $resp";
exit 0;
7 Einträge, 1 Seite |