PHP code example of fightbulc / jsonrpc_curl

1. Go to this page and download the library: Download fightbulc/jsonrpc_curl library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fightbulc / jsonrpc_curl example snippets


// load autoloader
rver
$urlServiceGateway = 'http://localhost/jsonrpc/';

// 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);

// 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);

// 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);