/**
  * Executes an API call
  * @param string $method API method to call
  * @param array $params Array of parameters
  * @return array
  * @access private
  */
 protected function execute($method, array $params = [])
 {
     $array = array($this->apiKey);
     if (!empty($params)) {
         $array[1] = $params;
     }
     if ($this->isBatch) {
         $this->client->call($method, $array);
         return $this;
     } else {
         $this->client->call($method, $array);
         $response = json_decode($this->client->output, true);
         return isset($response['result']) ? $response['result'] : $response['error'];
     }
 }
Example #2
0
<?php

require 'vendor/autoload.php';
$client = new JsonRPC\Client('http://127.0.0.1');
$num = 43454345;
$result = $client->execute('MSISDNLookup', [$num]);
echo '<pre>', 'number: ', $num, '<br />', var_export($result, true), '</pre>';
$num = 3864060507056;
$result = $client->execute('MSISDNLookup', [$num]);
echo '<pre>', 'number: ', $num, '<br />', var_export($result, true), '</pre>';
$num = '5466h466';
$result = $client->execute('MSISDNLookup', [$num]);
echo '<pre>', 'number: ', $num, '<br />', var_export($result, true), '</pre>';
 private function signal()
 {
     $client = new \JsonRPC\Client('http://localhost:4000');
     $result = $client->signal();
 }
Example #4
0
#!/usr/bin/env php
<?php 
require 'vendor/JsonRPC/Client.php';
if ($argc !== 3) {
    die('Usage: ' . $argv[0] . ' <url> <token>' . PHP_EOL);
}
$client = new JsonRPC\Client($argv[1], 5, true);
$client->authentication('jsonrpc', $argv[2]);
$client->createProject('Test API');
$r = $client->getAllProjects();
var_dump($r);