Exemple #1
0
 public function getServiceConfig()
 {
     return array('factories' => array('Changelog\\XmlRpc\\Client' => function ($services) {
         $config = $services->get('Config');
         if (!isset($config['changelog'])) {
             throw new RuntimeException('Expecting a "changelog" key in configuration; none found');
         }
         $config = $config['changelog'];
         if (!isset($config['jira']) || !is_array($config['jira'])) {
             throw new RuntimeException('Expecting an array of JIRA credentials in "changelog" configuration; none found');
         }
         $jiraUrl = isset($config['jira']['url']) ? $config['jira']['url'] : 'http://framework.zend.com/issues/rpc/xmlrpc';
         $cxn = new XmlRpcClient($jiraUrl);
         $client = $cxn->getProxy('jira1');
         return $client;
     }, 'Changelog\\Jira\\Auth' => function ($services) {
         $config = $services->get('Config');
         if (!isset($config['changelog'])) {
             throw new RuntimeException('Expecting a "changelog" key in configuration; none found');
         }
         $config = $config['changelog'];
         if (!isset($config['jira']) || !is_array($config['jira'])) {
             throw new RuntimeException('Expecting an array of JIRA credentials in "changelog" configuration; none found');
         }
         $jiraCredentials = $config['jira'];
         $client = $services->get('Changelog\\XmlRpc\\Client');
         $auth = $client->login($jiraCredentials['username'], $jiraCredentials['password']);
         return $auth;
     }, 'Changelog\\Http\\Client' => function ($services) {
         $client = new HttpClient();
         $client->setOptions(array('adapter' => 'Zend\\Http\\Client\\Adapter\\Curl', 'keepalive' => true, 'timeout' => 10));
         return $client;
     }));
 }
Exemple #2
0
 protected function setUpConnector()
 {
     $client = new Client('http://127.0.0.1:9001/RPC2');
     $client->getHttpClient()->setAuth('user', '123', HttpClient::AUTH_BASIC);
     $connector = new Zend($client);
     $this->supervisor = new Supervisor($connector);
 }
 public function testCheckConnection()
 {
     $map = [['a', 'b', 'c', 'd'], ['e', 'f', 'g', 'h']];
     $this->xmlRpcClient->method('call')->willReturnMap($map);
     $connection = new Connection($this->xmlRpcClient);
     $this->assertInternalType('int', $connection->checkConnection());
 }
Exemple #4
0
 /**
  * {@inheritdoc}
  */
 public function call($namespace, $method, array $arguments = [])
 {
     try {
         return $this->client->call($namespace . '.' . $method, $arguments);
     } catch (FaultException $e) {
         throw Fault::create($e->getMessage(), $e->getCode());
     }
 }
 /**
  * @return Zend_XmlRpc_Client
  */
 public function getClient()
 {
     if (!$this->client) {
         $client = new Client($this->getApiUrl());
         $client->setSkipSystemLookup(true);
         $this->client = SS_Cache::factory('wordpress_posts', 'Class', array('cached_entity' => $client, 'lifetime' => $this->getCacheLifetime()));
     }
     return $this->client;
 }
 /**
  * @param string     $username
  * @param string     $password
  * @param string     $hostname
  * @param int        $port
  * @param null|mixed $logger
  */
 public function __construct($username, $password, $hostname = '127.0.0.1', $port = 9001, $logger = null)
 {
     $this->_logger = $logger;
     // Connect to Supervsior XMLRPC server
     // MUST add '/RPC2' to URI!!!
     $xmlRpcClient = new Client("http://{$username}:{$password}@{$hostname}:{$port}/RPC2");
     $xmlRpcClient->setSkipSystemLookup(true);
     $this->_service = $xmlRpcClient->getProxy();
 }
 public function call($url, $method, $arguments, $userId = null)
 {
     if ($userId) {
         $this->userId = $userId;
     }
     if (!self::$token) {
         $this->authenticate();
     }
     $client = new XmlRpcClient(REALTIME_URL . $url);
     return $client->call($method, array_merge([self::$token], $arguments));
 }
 /**
  * @param string $method
  * @param array  $params
  *
  * @return mixed
  * @throws AuthenticationException
  * @throws ConnectionException
  * @throws SupervisorException
  */
 public function callMethod($method, array $params = [])
 {
     try {
         return $this->_connection->call($method, $params);
     } catch (RuntimeException $error) {
         throw new ConnectionException('Unable to connect to supervisor XML RPC server.');
     } catch (HttpException $error) {
         throw new AuthenticationException('Authentication failed. Check user name and password.');
     } catch (FaultException $error) {
         $methodName = isset($error->getTrace()[0]['args'][0]) ? $error->getTrace()[0]['args'][0] : 'Unknown';
         throw new SupervisorException('Method: ' . $methodName . ' was not found in supervisor RPC API.');
     }
 }
Exemple #9
0
 /**
  * Does a query to the RPC host
  *
  * @param string $method
  * @param array $search
  * @return bool|array
  */
 public function doQuery($method, $search)
 {
     try {
         $username = '******';
         $password = '******';
         $RpcClient = new RpcClient('http://172.17.100.201:1337/XMLRPC');
         $httpClient = $RpcClient->getHttpClient();
         $httpClient->setAuth($username, $password);
         $return = $RpcClient->call($method, $search);
     } catch (\Exception $e) {
         $return = false;
     }
     return $return;
 }
 /**
  * @param array $domainNames domain names
  * @param array $options
  * @return mixed
  */
 public function isAvailable(array $domainNames, array $options = null)
 {
     $maxRetry = 0;
     $gandi = $this->gandi->getProxy('domain');
     $results = $gandi->available($this->api_key, $domainNames, $options);
     foreach ($results as $domain => $result) {
         if ('pending' == $result) {
             $maxRetry++;
             //if max retry has expired, return the data as it.
             if ($maxRetry > self::MAX_TIMEOUT) {
                 return $this->convertDomainListToUTF8($results);
             }
             sleep(1);
             return $this->isAvailable($domainNames);
         }
     }
     return $this->convertDomainListToUTF8($results);
 }
Exemple #11
0
 /**
  * Send an XML-RPC request to the service (for a specific method)
  *
  * @param  string $method Name of the method we want to call
  * @param  array $params Array of parameters for the method
  * @param  string $requestType Type of the request \App\XmlRpc\Client::XMLRPC_REQUEST_*
  * @return mixed
  * @throws Zend_XmlRpc_Client_FaultException
  */
 public function call($method, $params = array(), $requestType = \App\XmlRpc\Client::XMLRPC_REQUEST_FAST)
 {
     $timeout = self::$_fastRequestTimeout;
     if ($requestType == self::XMLRPC_REQUEST_SLOW) {
         $timeout = self::$_slowRequestTimeout;
     }
     $this->getHttpClient()->setOptions(array('timeout' => $timeout));
     return parent::call($method, $params);
 }
Exemple #12
0
 /**
  * Get XmlRpc Client
  *
  * This method returns an XmlRpc Client for the requested endpoint.
  * If no endpoint is specified or if a client for the requested endpoint is
  * already initialized, the last used client will be returned.
  *
  * @param null|string $path The api endpoint
  *
  * @return XmlRpcClient
  */
 protected function getClient($path = null)
 {
     if ($path === null) {
         return $this->client;
     }
     if ($this->path === $path) {
         return $this->client;
     }
     $this->path = $path;
     $this->client = new XmlRpcClient($this->host . '/' . $path);
     // The introspection done by the Zend XmlRpc client is probably specific
     // to Zend XmlRpc servers. To prevent polution of the Odoo logs with errors
     // resulting from this introspection calls we disable it.
     $this->client->setSkipSystemLookup(true);
     return $this->client;
 }
Exemple #13
0
 /**
  * Call a method in this namespace.
  *
  * @param  string $methodN
  * @param  array $args
  * @return mixed
  */
 public function __call($method, $args)
 {
     $method = ltrim("$this->_namespace.$method", '.');
     return $this->_client->call($method, $args);
 }
Exemple #14
0
 /**
  * Call a method in this namespace.
  *
  * @param  string $method
  * @param  array $args
  * @return mixed
  */
 public function __call($method, $args)
 {
     $method = ltrim("{$this->namespace}.{$method}", '.');
     return $this->client->call($method, $args);
 }
Exemple #15
0
 function it_throws_a_known_exception_when_proper_fault_returned(Client $client)
 {
     $e = new FaultException('UNKNOWN_METHOD', 1);
     $client->call('namespace.method', [])->willThrow($e);
     $this->shouldThrow('Indigo\\Supervisor\\Exception\\Fault\\UnknownMethod')->duringCall('namespace', 'method');
 }
Exemple #16
0
 public function getProxy($namespace = '')
 {
     if (empty($this->_proxyCache[$namespace])) {
         $this->_proxyCache[$namespace] = new PythonSimpleXMLRPCServerWithUnsupportedIntrospection($this, $namespace);
     }
     return parent::getProxy($namespace);
 }
 /**
  * @param Zend\XmlRpc\Client $client
  */
 public function __construct(XMLRPCClient $client)
 {
     $this->_system = $client->getProxy('system');
 }
<?php

/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 * @package   Zend_XmlRpc
 */
use Zend\Loader\StandardAutoloader;
use Zend\XmlRpc\Client;
require_once dirname(dirname(dirname(__DIR__))) . '/library/Zend/Loader/StandardAutoloader.php';
$loader = new StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
$server = new Client('http://www.upcdatabase.com/xmlrpc');
$client = $server->getProxy();
print_r($client->lookup(array('rpc_key' => '0000...0000', 'upc' => '123456789012')));
Exemple #19
0
 /**
  * PingBackを送信
  */
 protected function sendPingBack()
 {
     $err = array();
     $links = array();
     // Wikiのソースのアドレスを取得
     if (preg_match_all('/(https?://[a-zA-Z0-9./~_]+)/', $wiki->get(), $links, PREG_PATTERN_ORDER) === false) {
         // ない場合そのままリターン
         return;
     }
     // 重複を削除
     $target_uris = array_unique($links[0]);
     foreach ($target_uris as $target_uri) {
         // 初期値
         $pingback = false;
         // ターゲットとなるURL接続
         $client = new Client($target_uri);
         // HEADメソッドで接続し、ヘッダーのみ取得
         $client->setMethod(Request::METHOD_HEAD);
         // 返り値を取得
         $response = $client->send();
         // アクセス失敗
         if (!$response->isSuccess()) {
             continue;
         }
         // 返り値のヘッダーからPingBackのURIを取得
         $pingback = $response->getHeaders()->get('x-pingback');
         // x-pingbackヘッダーがない場合(このへんの処理は重そう)
         if ($pingback === false) {
             try {
                 // GETでアクセスしてコンテンツを取得し、linkタグを探す。
                 $client->setMethod(Request::METHOD_GET);
                 // 返り値を取得
                 $response = $client->send();
                 // linkタグからPingBackのURIを取得
                 if (preg_match('<link rel="pingback" href="([^"]+)" ?/?>', $response->getBody(), $matches) !== false) {
                     $pingback = isset($matches[1]) ? $matches[1] : null;
                 }
             } catch (Exception $e) {
                 $err[] = $e;
             }
         }
         // PingBack送信先が見つからない場合スキップ
         if ($pingback === false) {
             continue;
         }
         unset($client, $response);
         // PingBackで送信する内容
         $request = new XmlRpcRequest();
         $request->setMethod('pingback.ping');
         $request->setParams(array($source_uri, $target_uri));
         // 例外を取得
         try {
             // PingBack送信先に接続
             $client = new XmlRpcClient($pingback);
             // 送信
             $client->doRequest($request);
         } catch (\Zend\XmlRpc\Client\Exception\FaultException $e) {
             $err[] = $e;
         }
         $err[] = '-----' . "\n";
         unset($client, $request);
     }
     return $err;
 }
Exemple #20
0
 /**
  * Clear all process log files
  *
  * @return boolean result Always return true
  */
 public function clearAllProcessLogs()
 {
     return $this->rpcClient->call('supervisor.clearAllProcessLogs');
 }
 /**
  * Format a success response
  *
  * @return string
  */
 public function getResponse()
 {
     $content = 'Response :' . "\n";
     $content .= static::logType($this->client->getLastResponse()->getReturnValue());
     return $content;
 }
Exemple #22
0
 /**
  * @return String
  */
 private function getCurrentGrid()
 {
     $gandi = $gandi = $this->gandi->getProxy('contact');
     $result = $gandi->balance($this->api_key);
     return $result['grid'];
 }
Exemple #23
0
 /**
  * Clear processLlogs
  *
  * @return boolean result Always True unless error
  */
 public function clearProcessLogs()
 {
     return $this->rpcClient->call('supervisor.clearProcessLogs', array($this->processGroup . ':' . $this->processName));
 }