2017 © Pedro Peláez
 

library jsonrpc-client

Jsonrpc client php implementation

image

moaction/jsonrpc-client

Jsonrpc client php implementation

  • Thursday, December 5, 2013
  • by nitso
  • Repository
  • 1 Watchers
  • 0 Stars
  • 79 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Jsonrpc-client

JSON-Rpc 2.0 protocol implementation, (*1)

http://www.jsonrpc.org/specification, (*2)

Installing

Add to yours composer.json require section:, (*3)

"moaction/jsonrpc-client": "1.*"

Usage

Basic usage

$client = new \Moaction\Jsonrpc\Client\ClientBasic('http://mys-server.org/jsonrpc/url');

$request = new \Moaction\Jsonrpc\Common\Request();
$request->setMethod('getUser');
$request->setParams(array('id' => 1));
// You have to set request id whenever you want to recieve response data. See `Notification request`
$request->setId(1);

$response = $client->call($request);
// $response now contains a \Moaction\Jsonrpc\Common\Response object

Notification request

Notification is a request without id. According to specification server must not reply on a request without id:, (*4)

When a rpc call is made, the Server MUST reply with a Response, except for in the case of Notifications., (*5)

$request = new \Moaction\Jsonrpc\Common\Request();
$request->setMethod('commentAdded');
$request->setParams(array(
    'userId' => 45,
    'commentId' => 471,
));

$client->call($request);

Batch request

 // first request
 $request1 = new \Moaction\Jsonrpc\Common\Request();
 $request1->setMethod('getUserInfo');
 $request1->setParams(array('id' => 1));
 $request1->setId(3);

 // second request
 $request2 = new \Moaction\Jsonrpc\Common\Request();
 $request2->setMethod('getUserComments');
 $request2->setParams(array('id' => 1));
 $request2->setId(7);

 // notification
 $request3 = new \Moaction\Jsonrpc\Common\Request();
 $request3->setMethod('loginSucceeded');
 $request3->setParams(array('id' => 1));

 $responses = $client->batch(array($request2, $request2, $request2));

 // now $responses contains array of request objects. Array keys are requests' ids.
 // array(
 //     3 => Request object,
 //     7 => Request object,
 // )

The Versions

05/12 2013

dev-master

9999999-dev

Jsonrpc client php implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexey Kalinin

05/12 2013

v1.4

1.4.0.0

Jsonrpc client php implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexey Kalinin

04/12 2013

v1.2

1.2.0.0

Jsonrpc client php implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexey Kalinin

04/12 2013

v1.1

1.1.0.0

Jsonrpc client php implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexey Kalinin

04/12 2013

v1.0

1.0.0.0

Jsonrpc client php implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexey Kalinin