PHP code example of foglcz / jsonrpc2

1. Go to this page and download the library: Download foglcz/jsonrpc2 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/ */

    

foglcz / jsonrpc2 example snippets




$server = new Lightbulb\Json\Rpc2\Server;

// Add functions to the server object to make them callable remotely

// Built in PHP functions or user functions
$server->upper = 'strtoupper';
$server->getID = 'findUserID';

// Class based: All public methods in MyClass are exposed as user.method
$server->user = new MyClass;

// Receive and process any incoming RPC calls
$server->handle();

$url    = 'http://api.domain.com/endpoint';
$client = new Lightbulb\Json\Rpc2\Client($url);

$str = $client->upper("kitten");
$id  = $client->getID("Jason Doolis");

$ok = $client->user->mail->login($user, $pass); // Maps to 'user.mail.login'