<?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);
/** * Constructor * * @param string $url Multichain JSON RPC url + port * @param string $username Multichain JSON RPC username * @param string $password Multichain JSON RPC password * @param integer $timeout HTTP timeout */ public function __construct($url, $username, $password, $timeout = 3) { $this->jsonRPCClient = new JsonRPCClient($url); $httpClient = $this->jsonRPCClient->getHttpClient(); $httpClient->withHeaders($this->headers); $this->jsonRPCClient->authentication($username, $password); }
/** * Inits Client Connection based on instance params * @return JsonRPC\Client */ private function connection_init() { $opts = $this->config; // Headers format $headers = []; foreach ($opts['headers'] as $key => $value) { $headers[] = "{$key}: {$value}"; } $connection = new JsonRPC\Client($opts['url'], $opts['timeout'], $headers); $connection->ssl_verify_peer = $opts['ssl_verify_peer']; $connection->debug = $opts['debug']; if (isset($opts['username']) && $opts['username']) { $connection->authentication($opts['username'], $opts['password']); } return $connection; }
$trellotoken = $argv[4]; $trelloboard = $argv[5]; $userId = null; if (isset($argv[6])) { $userId = $argv[6]; } $jsonString = file_get_contents("https://trello.com/1/boards/" . $trelloboard . "?key=" . $trellokey . "&token=" . $trellotoken); $trelloObj = json_decode($jsonString); if (empty($trelloObj)) { printf($jsonString); printf('Unable to parse JSON response, is it valid? %s', json_last_error_msg()); die(1); } //initialize the client $client = new Client($server); $client->authentication('jsonrpc', $token); //verify that we can connect $projects = null; try { $projects = $client->getAllProjects(); } catch (RuntimeException $e) { $projects = null; //explicitly set it to null, to trigger an error } $users = $client->getAllUsers(); foreach ($users as $user) { if ($user['username'] == $userId || $userId == null) { $userId = $user['id']; } } if (!is_array($projects)) {
<?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"]]);