Brad Gilbert > JSON-RPC-LWP > JSON::RPC::LWP

Download:
JSON-RPC-LWP-0.007.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.007   Source  

NAME ^

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

VERSION ^

version 0.007

SYNOPSIS ^

    use JSON::RPC::LWP;

    my $rpc = JSON::RPC::LWP->new(
      from  => 'name@address.com',
      agent => '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

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

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

This attribute is deprecated, and will always return 1 immediately after a call.

has_previous_id

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

This method is deprecated.

clear_previous_id

This method is deprecated.

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

id_generator

This attribute is deprecated, and is no longer used.

If you modified it in a subclass:

    has '+id_generator' => (
      default => sub{sub{1}},
    );

You should change it to only be modified on older versions of this module.

    unless( eval{ JSON::RPC::LWP->VERSION(0.007); 1 } ){
      # was always called with ( id => "1" )
      has '+id_generator' => (
        default => sub{sub{1}},
      );
    }

If anyone was actually relying on this feature it might get added back in.

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.

syntax highlighting: