NAME

JSON::RPC::LWP - Use any version of JSON RPC over any libwww supported transport protocols.

VERSION

version 0.005

SYNOPSIS

use JSON::RPC::LWP;

my $rpc = JSON::RPC::LWP->new;
$rpc->from('name@address.com');
$rpc->agent('JSON::RPC::LWP Example');

my $login = $rpc->call(
  'https://us1.lacunaexpanse.com/empire', # uri
  'login', # service
  [$empire,$password,$api_key] # JSON container
);

METHODS

call( $uri, $method )
call( $uri, $method, {...} )
call( $uri, $method, [...] )
call( $uri, $method, param1, param2, ... )

Initiate a JSON::RPC::Common::Procedure::Call

Uses LWP::UserAgent for transport.

Then returns a JSON::RPC::Common::Procedure::Return

notify( $uri, $method )
notify( $uri, $method, {...} )
notify( $uri, $method, [...] )
notify( $uri, $method, param1, param2, ... )

Initiate a JSON::RPC::Common::Procedure::Call

Uses LWP::UserAgent for transport.

Basically this is the same as a call, except without the id key, and doesn't expect a JSON RPC result.

Returns the HTTP::Response from ua.

To check for an error use the is_error method of the returned response object.

ATTRIBUTES

previous_id

Returns the previous id used in the call() method.

has_previous_id

Returns true if the previous_id has any value associated with it.

clear_previous_id

Clears the previous id, useful for generators that do something different the first time they are used.

id_generator

This is used for generating the next id to be used in the call() method.

The default is just an incrementing subroutine.

The call-back gets called with 1 or 2 arguments.

The first is the object which is calling it.

The secound is the previous id, if the object has one.

The previous_id attribute gets set to the return value of the call-back before the call actually goes through

The reason for this attribute, is to make it easy to change the order of the id's that get used.

version

The JSON RPC version to use. one of 1.0 1.1 or 2.0

agent

Get/set the product token that is used to identify the user agent on the network. The agent value is sent as the "User-Agent" header in the requests. The default is the string returned by the _agent attribute (see below).

If the agent ends with space then the _agent string is appended to it.

The user agent string should be one or more simple product identifiers with an optional version number separated by the "/" character.

Setting this will also set ua->agent and marshal->user_agent.

_agent

Returns the default agent identifier. This is a string of the form "JSON-RPC-LWP/#.###", where "#.###" is substituted with the version number of this library.

marshal

An instance of JSON::RPC::Common::Marshal::HTTP. This is used to convert from a JSON::RPC::Common::Procedure::Call to a HTTP::Request, and from an HTTP::Response to a JSON::RPC::Common::Procedure::Return.

Attributes delegated to marshal

prefer_get
rest_style_methods
prefer_encoded_get
ua

An instance of LWP::UserAgent. This is used for the transport layer.

Attributes delegated to ua

timeout
proxy
no_proxy
env_proxy
from
credentials

AUTHOR

Brad Gilbert <b2gills@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Brad Gilbert.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.