コード例 #1
0
 /**
  * Sets the API key and instantiates the XML-RPC client
  *
  * @param  string $apiKey
  * @return void
  */
 public function __construct($apiKey)
 {
     $this->_apiKey = (string) $apiKey;
     /**
      * @see Zend_XmlRpc_Client
      */
     require_once 'Zend/XmlRpc/Client.php';
     try {
         $this->_client = new Zend_XmlRpc_Client('https://rpc.gandi.net/xmlrpc/2.0');
         $this->_client->setSkipSystemLookup(true);
     } catch (Zend_XmlRpc_Client_FaultException $e) {
         throw new Exception('Fault Exception: ' . $e->getCode() . "\n" . $e->getMessage());
     } catch (Zend_XmlRpc_Client_HttpException $e) {
         throw new Exception('HTTP Exception: ' . $e->getCode() . "\n" . $e->getMessage());
     }
 }
コード例 #2
0
 public function testSkipsSystemCallWhenDirected()
 {
     $this->mockHttpClient();
     $this->mockedHttpClient->expects($this->once())->method('request')->with('POST')->will($this->returnValue($this->makeHttpResponseFor('foo')));
     $this->xmlrpcClient->setHttpClient($this->mockedHttpClient);
     $this->xmlrpcClient->setSkipSystemLookup(true);
     $this->assertSame('foo', $this->xmlrpcClient->call('test.method'));
 }
コード例 #3
0
ファイル: ClientTest.php プロジェクト: navassouza/zf2
 public function testSkipsSystemCallWhenDirected()
 {
     $httpAdapter = $this->httpAdapter;
     $response = $this->makeHttpResponseFor('foo');
     $httpAdapter->setResponse($response);
     $this->xmlrpcClient->setSkipSystemLookup(true);
     $this->assertSame('foo', $this->xmlrpcClient->call('test.method'));
 }
コード例 #4
0
ファイル: Webservice.php プロジェクト: cwcw/cms
 /**
  * Retrieve client object
  *
  * @return Zend_XmlRpc_Client
  */
 public function getWebserviceClient()
 {
     if (is_null($this->_client)) {
         if ($this->_options['so']) {
             $this->_client = new Streamwide_Web_Webservice_Client($this->_options['serverUrl'], $this->getOptions());
         } else {
             $this->_client = new Zend_XmlRpc_Client($this->_options['serverUrl']);
             $this->_client->setSkipSystemLookup(true);
         }
     }
     return $this->_client;
 }
 /**
  * @return Zend_XmlRpc_Client
  */
 public function getClient()
 {
     if (!$this->client) {
         $client = new Zend_XmlRpc_Client($this->getApiUrl());
         $client->setSkipSystemLookup(true);
         $this->client = SS_Cache::factory('drupal_menu', 'Class', array('cached_entity' => $client, 'lifetime' => $this->getCacheLifetime()));
         /*
         TODO: authenticate, to avoid hacking perms in Drupal.
         $result = $this->client->call('user.login', array($this->Username, $this->Password));
         $sessionName = $result['session_name'];
         $sessid = $result['sessid'];
         */
     }
     return $this->client;
 }
コード例 #6
0
ファイル: SF_API.php プロジェクト: pombredanne/spamfighter
 /**
  * Конструктор.
  * 
  * @param string $api_url URL доступа к API Спамоборца 
  */
 public function __construct($api_url = "http://localhost:8000/api/xml/")
 {
     $this->api_transport = new Zend_XmlRpc_Client($api_url);
     $this->api_transport->setSkipSystemLookup(true);
 }
 /**
  * @return Zend_XmlRpc_Client
  */
 public function getClient()
 {
     if (!$this->client) {
         $client = new Zend_XmlRpc_Client($this->getApiUrl());
         $client->setSkipSystemLookup(true);
         /*$this->client = SS_Cache::factory('drupal_content_source', 'Class', array(
         			'cached_entity' => $client,
         			'lifetime' => $this->getCacheLifetime()
         		));*/
         $this->client = $client;
     }
     return $this->client;
 }
コード例 #8
0
$frontendOptions = array('debug_header' => false, 'caching' => true, 'lifetime' => (int) $config->cache->page->lifetime, 'logging' => true, 'logger' => $logger, 'ignore_user_abort' => true, 'default_options' => array('cache' => true, 'make_id_with_get_variables' => false, 'make_id_with_post_variables' => false, 'make_id_with_session_variables' => false, 'make_id_with_files_variables' => false, 'make_id_with_cookie_variables' => false), 'regexps' => array('^.*$' => array('cache' => false), '^/$' => array('cache' => true)));
$backendOptions = array('cache_dir' => $config->cache->dir, 'file_name_prefix' => $config->cache->page->prefix, 'cache_file_umask' => 0777);
try {
    if (!is_dir($config->cache->dir)) {
        mkdir($config->cache->dir, 0777);
    }
    $cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions);
    $cache->start();
    $logger->log('start cache', Zend_Log::DEBUG);
} catch (Zend_Cache_Exception $e) {
    echo 'Exception: ' . $e->getCode() . "\n" . $e->__toString();
    exit;
}
// GANDI XML-RPC
$client = new Zend_XmlRpc_Client($config->gandi->api);
$client->setSkipSystemLookup(true);
try {
    $account = $client->call('account.info', array($config->gandi->apikey));
    $vm_list = $client->call('vm.list', array($config->gandi->apikey));
} catch (Zend_XmlRpc_Client_FaultException $e) {
    echo 'Exception: ' . $e->getCode() . "\n" . $e->getMessage();
    exit;
} catch (Zend_XmlRpc_Client_HttpException $e) {
    echo 'Exception: ' . $e->getCode() . "\n" . $e->getMessage();
    exit;
}
// account
if ($config->gandi->account->showdetails) {
    $fullname = $account['fullname'];
    $resGranted = array('servers' => $account['resources']["granted"]["servers"], 'ips' => $account['resources']["granted"]["ips"], 'bandwidth' => $account['resources']["granted"]["bandwidth"], 'memory' => $account['resources']["granted"]["memory"], 'cores' => $account['resources']["granted"]["cores"], 'disk' => $account['resources']["granted"]["disk"]);
    ?>