1. Go to this page and download the library: Download mdjward/php-rpc-client 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/ */
mdjward / php-rpc-client example snippets
use Guzzle\Http\Client;
use Mdjward\RpcApi\RequestInitiator;
use Mdjward\RpcApi\RequestEncoder\JsonRpc\JsonRpcV2Encoder;
// Initialise the Guzzle client to the JSON RPC endpoint offered by XBMC
$client = new Client("http://xbmc.myhomenetwork.org:8080/jsonrpc");
// Initialise an object of the prescribed class for encoding/decoding JSON RPC v2 messages
$encoder = new JsonRpcV2Encoder();
// Initialise the initiator!
$initiator = new RequestInitiator($client, $encoder);
// Invoke the Scan method and store the response in variable $response
$response = $initiator->VideoLibrary->Scan("");
// ...
class XbmcRequestInitiator extends RequestInitiator {
public $videoLibrary;
public function __construct(Client $client, JsonRpcV2Encoder $encoder) {
parent::__construct($client, $encoder, "");
$this->videoLibrary = new VideoLibraryRequestInitiator($client, $encoder);
}
}
// ...
class VideoLibraryRequestInitiator extends RequestInitiator {
public function __construct(Client $client, JsonRpcV2Encoder $encoder) {
parent::__construct($client, $encoder, "VideoLibrary");
}
public function scan($directory = "") {
return $this->__call("Scan", array("directory" => $directory);
}
}
// ...
// Initialise the XBMC initiator!
$initiator = new XbmcRequestInitiator($client, $encoder);
// Invoke the Scan method and store the response in variable $response
$response = $initiator->videoLibrary->scan("");
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.