2017 © Pedro Peláez
 

library jsonrpc_curl

JSON-RPC CURL

image

fightbulc/jsonrpc_curl

JSON-RPC CURL

  • Tuesday, May 14, 2013
  • by fightbulc
  • Repository
  • 1 Watchers
  • 0 Stars
  • 36,576 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 6 % Grown

The README.md

::::::'##::'######:::'#######::'##::: ##:'########::'########:::'######::
:::::: ##:'##... ##:'##.... ##: ###:: ##: ##.... ##: ##.... ##:'##... ##:
:::::: ##: ##:::..:: ##:::: ##: ####: ##: ##:::: ##: ##:::: ##: ##:::..::
:::::: ##:. ######:: ##:::: ##: ## ## ##: ########:: ########:: ##:::::::
'##::: ##::..... ##: ##:::: ##: ##. ####: ##.. ##::: ##.....::: ##:::::::
 ##::: ##:'##::: ##: ##:::: ##: ##:. ###: ##::. ##:: ##:::::::: ##::: ##:
. ######::. ######::. #######:: ##::. ##: ##:::. ##: ##::::::::. ######::
:......::::......::::.......:::..::::..::..:::::..::..::::::::::......:::
:'######::'##::::'##:'########::'##:::::::
'##... ##: ##:::: ##: ##.... ##: ##:::::::
 ##:::..:: ##:::: ##: ##:::: ##: ##:::::::
 ##::::::: ##:::: ##: ########:: ##:::::::
 ##::::::: ##:::: ##: ##.. ##::: ##:::::::
 ##::: ##: ##:::: ##: ##::. ##:: ##:::::::
. ######::. #######:: ##:::. ##: ########:
:......::::.......:::..:::::..::........::

JSON-RPC CURL

A tiny JSON-RPC client which works perfectly with Simplon/Jr - a JSON-RPC server., (*1)

1. Installation

You can install JSONRPC CURL either via package download from github or via Composer install. I encourage you to do the latter:, (*2)

{
  "require": {
    "fightbulc/jsonrpc_curl": "0.5.2"
  }
}

2. How to use?

If you are new to the topic of JSON-RPC I would suggest you to jump over to Simplon/Jr's documentation which explains the whole topic. Go ahead I will wait here..., (*3)

Got it? Cool!, (*4)

The following code examples should help you understand how to use the client. First off, we need load composer's autoloader. Secondly, since we require a JSON-RPC server lets assume that our server resides under the following URL:, (*5)

// load autoloader
require __DIR__ . '/vendor/autoload.php';       // set correct composer vendor path

// set url for server
$urlServiceGateway = 'http://localhost/jsonrpc/';

2.1. Request without data

Sending an request without data:, (*6)

// send request without parameters
$response = (new JsonRpcCurl())
  ->setUrl($urlServiceGateway . '/api/web/')    // server url with gateway path
  ->setId(1)                                    // request ID (important for batch/async)
  ->setMethod('Web.Base.helloWorld')            // requested service
  ->send();                                     // send request

// dump response
var_dump($response);

2.2. Request with data

Data are passed via an assoc. array:, (*7)

// set data
$data = [
  'address'  => 'Mr.',
  'lastname' => 'Putterschmidt',
];

// send request without parameters
$response = (new JsonRpcCurl())
  ->setUrl($urlServiceGateway . '/api/web/')    // server url with gateway path
  ->setId(1)                                    // request ID (important for batch/async)
  ->setMethod('Web.Family.guy')                 // requested service
  ->setData($data)                              // holds data
  ->send();                                     // send request

// dump response
var_dump($response);

2.3. Proxy a request

In development I am using Charles to see all communication between server and client. The following example shows how to enable a proxy:, (*8)

// proxy
$proxyIp = '127.0.0.1';
$proxyPort = 88;

// set data
$data = [
  'message'  => 'Can I get a what whaaaat?',
];

// send request without parameters
$response = (new JsonRpcCurl())
  ->setUrl($urlServiceGateway . '/api/web/')    // server url with gateway path
  ->setId(1)                                    // request ID (important for batch/async)
  ->setMethod('Web.Cheerleader.cheer')          // requested service
  ->setData($data)                              // holds data
  ->setProxy($proxyIp, $proxyPort)              // enable proxy
  ->send();                                     // send request

// dump response
var_dump($response);

3. Conclusion

That's pretty much all there is. Cheers!, (*9)

The Versions

14/05 2013

dev-master

9999999-dev https://github.com/fightbulc/jsonrpc_curl

JSON-RPC CURL

  Sources   Download

MIT

The Requires

 

by Tino Ehrich

json-rpc client

14/05 2013

0.5.4

0.5.4.0 https://github.com/fightbulc/jsonrpc_curl

JSON-RPC CURL

  Sources   Download

MIT

The Requires

 

by Tino Ehrich

json-rpc client

26/03 2013

0.5.3

0.5.3.0 https://github.com/fightbulc/jsonrpc_curl

JSON-RPC CURL

  Sources   Download

MIT

The Requires

 

by Tino Ehrich

json-rpc client

11/03 2013

0.5.2

0.5.2.0 https://github.com/fightbulc/jsonrpc_curl

JSON-RPC CURL

  Sources   Download

MIT

The Requires

 

by Tino Ehrich

json-rpc-client

11/03 2013

0.5.1

0.5.1.0 https://github.com/fightbulc/jsonrpc_curl

JSON-RPC CURL

  Sources   Download

MIT

The Requires

 

by Tino Ehrich

json-rpc-client

04/03 2013

0.5.0

0.5.0.0 https://github.com/fightbulc/jsonrpc_curl

JSON-RPC CURL

  Sources   Download

MIT

The Requires

 

by Tino Ehrich

json-rpc-client