NAME
JSON::RPC::Simple::Client - JSON-RPC 1.1 WD client
SYNOPSIS
use JSON::RPC::Simple::Client;
my $c = JSON::RPC::Simple::Client->new("https://www.example.com/json-rpc");
my $results = $c->echo("foo");
USAGE
This class uses an AUTOLOAD subroutine so that any method calls are sent to the target JSON-RPC service.
To create a new client either use the new
method in directly or via the helper function JSON::RPC::Simple-
connect>.
- new (URL)
- new (URL, \%OPTIONS)
-
Creates a new client whos endpoint is given in URL.
Valid options:
- agent
-
What to send as HTTP User-Agent, defaults to "JSON::RPC::Simple <version>" where version is the current version number of the JSON::RPC::Simple package.
- timeout
-
Timeout for how long the call may take. Is passed to LWP::UserAgent which is used to make the request by default. Defaults to 180 sec
- json
-
The JSON encoder/decoder to use. Defaults to JSON->new->utf8. The supplied object/class must respond to
encode
anddecode
. - debug
-
Turn on debugging which prints to STDERR.
Using another transporter than LWP::UserAgent
By default this class uses LWP::UserAgent. If you wish to use something else such as for example WWW::Curl simply replace the ua
member of the instance with something that provides a LWP::UserAgent compatible API for post
. The returned object from the post
method is expected to provide is_success
, decoded_content
and content_type
.