PHP code example of hernandev / light-rpc

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

    

hernandev / light-rpc example snippets



// alias.
use LightRPC\Client;

// start a client instance.
$client = new Client('https://api.steemit.com');

// call it.
$response = $client->call('follow_api', 'get_follow_count', ['hernandev']);



// alias.
use LightRPC\Client;
use LightRPC\Request;

// start a client instance.
$client = new Client('https://api.steemit.com');

// create a request instance.
$request = new Request('follow_api', 'get_follow_count', ['hernandev']);

// send it.
$response = $client->send($request);



// wanna check for errors?
$response->isError();


// use the magic result getters.
$response->account;           // 'hernandev'
$response->follower_count;    // 123
$response->following_count;   // 123

// OR

// use a get method:
$response->get('account');           // 'hernandev'
$response->get('follower_count');    // 123
$response->get('following_count');   // 123

// OR

// get all result OR error data:
$response->data();  // [ 'account' => 'hernandev', 'following_count' => 123, 'follower_count' => 123]
$response->get();   // [ 'account' => 'hernandev', 'following_count' => 123, 'follower_count' => 123]

// OR

// If you are a boring person, just get the full response as array.
$response->toArray(); // [ 'jsonrpc' => '2.0', 'id' => 0, 'result' => ['foo' => 'bar']]

// You are really boring you know, wanna as JSON string?
(string) $response; // '{"jsonrpc":"2.0","id":0,"result":{...}}