<?php require 'kanboard_mailtasks_config.inc.php'; require 'kanboard_mailtasks_helpers.php'; require '../vendor/autoload.php'; use JsonRPC\Client; $projects = array(); $tasks = array(); // Let's call Kanboard $client = new JsonRPC\Client($jsonrpc_url); $client->authentication($jsonrpc_auth_name, $jsonrpc_auth_token); // We need the projects list $projects_tmp = $client->execute('getAllProjects'); // For each project, get identifier (if existing) and numeric ID foreach ($projects_tmp as $proj) { if ($proj['identifier']) { $projects[$proj['identifier']]['id'] = $proj['id']; } } // Now to the mails $imap_client = imap_open($imap_server, $imap_account, $imap_pass); if (!$imap_client) { echo imap_last_error(); exit; } // Give me the unseen mails list $emails_list = imap_search($imap_client, 'UNSEEN'); if ($emails_list) { // One by one we fetch unseen mails foreach ($emails_list as $email_id) { do_debug('Open mail ' . $email_id);
/** * Make a call to Aria2 RPC * * @param string $name * @param array $arguments * * @return mixed */ public function __call($name, $arguments) { if ($this->token) { array_unshift($arguments, 'token:' . $this->token); } return $this->client->execute('aria2.' . $name, $arguments); }
function Run() { $mode = $this->GetParam('mode', 'str'); $server = $this->GetParam('server', 'str'); $title = $this->GetParam('title', 'str'); $message = $this->GetParam('message', 'raw'); $image = $this->GetParam('image', 'str'); $time = $this->GetParam('time', 'float'); $custom = $this->GetParam('custom', 'raw'); $message = str_replace('{custom}', $custom, $message); if ($server) { $server_url = "http://{$server}/jsonrpc"; require_once $this->conf['libs']['jsonrpc_client']; $o_jsonrpc = new Client($server_url); //$o_jsonrpc = new Client($server_url,5,true); //debug } else { $this->DisplayJson(false, array('code' => 500, 'message' => "Server is not set!")); } $result = ''; $p = array(); $missing_parameters = true; if ($mode == 'notify') { if ($title and $message) { $missing_parameters = false; $method = "GUI.ShowNotification"; $p['title'] = $title; $p['message'] = $message; $image and $p['image'] = $image; $time and $p['displaytime'] = round($time * 1000); } } elseif ($mode == 'pause') { $missing_parameters = false; $method = "Player.PlayPause"; $p['playerid'] = 1; } else { $this->DisplayJson(false, array('code' => 404, 'message' => "Invalid mode : {$mode}")); } if ($missing_parameters) { $this->DisplayJson(false, array('code' => 500, 'message' => "Missing some parameters!")); } $result = $o_jsonrpc->execute($method, $p); $data = array("sent_url" => $server_url, "sent_method" => $method, "sent_parameters" => $p, "api_result" => $result); if ($result == 'OK') { $data['code'] = 200; $data['message'] = "Sucessfully sent mode: {$mode}"; $this->DisplayJson(true, $data); } else { $data['code'] = 500; $data['message'] = "Request failed!"; $this->DisplayJson(false, $data); } }
<?php require '../vendor/autoload.php'; // From https://github.com/fguillot/JsonRPC use JsonRPC\Client; $client = new Client('http://geocoding.geo.census.gov/geocoder/geographies'); $client->debug = true; $result = $client->execute('address', array('street' => '210 W 19th terrace', 'city' => 'Kansas City', 'state' => 'MO', 'zip' => '', 'benchmark' => 4, 'vintage' => 4, 'format' => 'json')); var_dump($result);
/** * Submits raw transaction (serialized, hex-encoded) to local node and network. * Returns the transaction hash in hex * * @param $hex * @param bool $allowHighFees * @return mixed */ public function sendRawTransaction($hex, $allowHighFees = false) { return $this->jsonRPCClient->execute("sendrawtransaction", array($hex, $allowHighFees)); }
/** * @expectedException JsonRPC\ConnectionFailureException */ public function testBadUrl() { $client = new Client('http://something_not_found/', 1); $client->execute('plop'); }
protected function _call($method, $params = []) { array_unshift($params, $this->_key); $client = new Client(self::API_PATH); return $client->execute($method, $params); }
<?php // TODO: // * Empty entries // * API rate-limited? require "config.php"; require __DIR__ . '/vendor/autoload.php'; use JsonRPC\Client; try { // Create API connection $client = new Client($BASE_MINIFLUX_URL . '/jsonrpc.php'); $client->authentication('admin', $API_PASSWORD); // Handle mark as read if (!empty($_GET["entry"])) { $client->execute('item.mark_as_read', ['item_id' => $_GET['entry']]); exit('{}'); } if (!empty($_GET["all"])) { $client->execute('item.mark_all_as_read'); exit('{}'); } // Fetch data $feeds = $client->execute('feed.list'); $entries = []; foreach ($feeds as $feed) { if (!$feed["enabled"]) { continue; } // Update old feeds if (time() - $feed["last_checked"] >= 3600) { $client->execute('feed.update', ["feed_id" => $feed["id"]]);
<pre><?php require './vendor/autoload.php'; use JsonRPC\Client; $client = new Client('http://localhost/server.php'); $result = $client->execute('doSomething', [3, 5]); var_dump($result);