function send() { //$api = new \KiWiApi(); try { $connection = \Tivoka\Client::connect(array('host' => '127.0.0.1', 'port' => 9040)); $connection->setTimeout(60); //$request = $connection->sendRequest('status_message', ['Limit Message',30]); //$request = $connection->sendRequest('flash_message', ["Archana Some FLASH"]); //$request = $connection->sendRequest('open_untitled', ["Python File","var i = 0"]); //$request = $connection->sendRequest('arch', []); //$request = $connection->sendRequest('register_event', ['/home/yash/Projects/kiwi/Build/Debug/resources/snippets/html/base/html','text_changed','php interface.php cool']); $request1 = Tivoka\Client::request('register_event_type', ['1_type' => 'Php File', '2_signal' => 'on_text_changed', '3_command' => 'php interface.php cool']); $request2 = Tivoka\Client::request('register_event_type', ['1_type' => 'Php File', '2_signal' => 'on_text_changed', '3_command' => 'php interface.php some']); $request3 = Tivoka\Client::request('register_event_pattern', ['php:php5', 'on_text_changed', 'php interface.php tuk']); #$connection->send($request1 , $request2, $request3); $str = 'register_event_pattern|php:php5,on_text_changed,php interface.php tuk;'; $str .= 'register_event_type|Php File,on_text_changed,php interface.php some;'; $request4 = Tivoka\Client::request('register_event', [$str]); $connection->send($request4); #$request = $connection->sendRequest('register_event_path', ['/home/yash/Projects/kiwi/Build/Debug/resources/snippets/html/base/html','text_changed','php interface.php cool']); #echo "\nJSON ".$request->result; } catch (Tivoka\Exception\ConnectionException $e) { echo "\nIDE is not running\n\n"; } //$api->callApi( 'updateAutocompleteModel', [$this->json] ); }
private function get_connection($url) { $conn = Tivoka\Client::connect($url); if ($this->cookie !== False) { $conn->setHeader('Cookie', $this->cookie); } return $conn; }
function call_kiwi($method, $args) { $connection = \Tivoka\Client::connect(array('host' => '127.0.0.1', 'port' => 9040)); //$request = $connection->sendRequest('text',array('file_name'=> $v->file_path )); $request = $connection->sendRequest($method, $args); if (!$request->isError()) { //$r = runkit_lint( $request->result ); $r = $request->result; return $request; } else { print 'Error ' . $request->error . ': ' . $request->errorMessage; var_dump($request->errorData); return ""; } }
/** * Get or cache a page via RPC. * * This uses phpfastcache and Tivoka to retrieve some data from either * the local cache or the local RPC server, based on parameters passed. * * It will return $default_result, whatever that is set to on a failure. * * @param string $method The URL to get or cache * @param string $cache_filename The name of the cache file to save to * @param array $cache_opts An array of options to pass to the cache * @param array $method_args An array of options to append to the method */ protected function getOrCache($method, $cache_filename, $cache_opts, $method_args) { try { $result = $this->cache->getOrCreate($cache_filename, $cache_opts, function ($filename) use($method, $method_args) { $url = $this->url; $client = \Tivoka\Client::connect($url); $client->useSpec('1.0'); // The data needs to be sensibly serialised for storage return serialize($client->sendRequest($method, $method_args)->result); }); } catch (\Exception $e) { throw new RPCException($e->getMessage()); } // Now we can safely unserialize it again return unserialize($result); }
/** * @param string $host The host name of the simPRO installation. If a port is required, it can be in the format '{hostName}:{port}' * @param \Eher\OAuth\Consumer $consumer * @param \Eher\OAuth\Token $accessToken * * @throws \Exception */ public function __construct($host, OAuthConsumer $consumer, OAuthToken $accessToken = null, OAuthSignatureMethod $signatureMethod = null) { // check the host name if (!$this->isValidHost($host)) { throw new \Exception("Invalid host: '{$host}'"); } // set the consumer, token & signature method $this->consumer = $consumer; $this->accessToken = $accessToken; if ($signatureMethod === null) { $signatureMethod = new \Eher\OAuth\HmacSha1(); } $this->signatureMethod = $signatureMethod; // set the host $this->host = $host; // generate the API URL from the host $url = sprintf(self::API_URL, $this->host); // create a JSON-RPC client connection to the url $this->connection = \Tivoka\Client::connect($url); // configure the specification setting $this->connection->useSpec(1.0); // Default the logger to null - can be overwritten using setLogger $this->logger = new \Psr\Log\NullLogger(); }
public function send() { //$api = new \KiWiApi(); $connection = \Tivoka\Client::connect(array('host' => '127.0.0.1', 'port' => 9040)); $request = $connection->sendRequest('updateAutocompleteModel', [$this->json]); /*$request = $connection->sendRequest('showFlash', ["Some FLASH"]);*/ echo "\nJSON " . $this->json; //$api->callApi( 'updateAutocompleteModel', [$this->json] ); }
/** * Returns set-up bitcoind json-rpc client. * * @return Tivoka\Client */ protected function getBitcoindConnection() { if (isset($this->bitcoindConnection)) { return $this->bitcoindConnection; } $this->bitcoindConnection = Tivoka::connect("http://{$this->bitcoindUsername}:{$this->bitcoindPassword}@localhost:8332/"); $this->bitcoindConnection->useSpec('1.0'); return $this->bitcoindConnection; }