public function ping() { $site_title = $this->app->config->site->title; $site_uri = $this->getSiteUri(); $post_uri = $this->getPostUri(); $atom_uri = $this->getAtomUri(); $post_tags = $this->getPostTags(); $this->client->extendedPing($site_title, $site_uri, $post_uri, $atom_uri, $post_tags); }
/** * Construct a new XML_RPC2_Client PHP Backend. * * To create a new XML_RPC2_Client, a URI must be provided (e.g. http://xmlrpc.example.com/1.0/). * Optionally, some options may be set * * @param string URI for the XML-RPC server * @param array (optional) Associative array of options */ public function __construct($uri, $options = array()) { parent::__construct($uri, $options); if ($this->encoding != 'utf-8') { throw new XML_RPC2_Exception('XML_RPC2_Backend_Php does not support any encoding other than utf-8, due to a simplexml limitation'); } }
/** * Constructor * * @param struct $credentials Credentials provided by the intraface system (public_key and session_id) * @param integer $site_id Site id * @param boolean $debug Whether to have debug turned on * @param string $url Url to use * * @return void */ public function __construct($credentials, $site_id, $debug = false, $url = 'http://www.intraface.dk/xmlrpc/cms/server2.php') { $this->options['debug'] = $debug; $this->credentials = $credentials; $this->site_id = intval($site_id); $this->client = XML_RPC2_Client::create($url, $this->options); if (PEAR::isError($this->client)) { die('error creating client ' . $this->client->getMessage()); } }
/** * Constructor * * @param struct $credentials Credentials provided by the intraface system (public_key and session_id) * @param integer $site_id Site id * @param boolean $debug Whether to have debug turned on * @param string $url Url to use * * @return void */ public function __construct($credentials, $site_id, $debug = false, $url = '', $encoding = 'iso-8859-1') { parent::__construct($encoding); if ($url == '') { $url = 'http://www.intraface.dk/xmlrpc/cms/server0300.php'; } $this->options['debug'] = $debug; $this->credentials = $credentials; $this->site_id = intval($site_id); $this->client = XML_RPC2_Client::create($url, $this->options); if (PEAR::isError($this->client)) { throw new Exception($this->client->getMessage()); } }
public static function get_library_operation_hours($library_id, $term_id, $date = NULL, $shorten = false) { $str = ''; if ($date == NULL) { $date = time(); } try { $client = \XML_RPC2_Client::create(HoursConstants::XML_RPC_FULL_URL, HoursConstants::get_xml_rpc_options()); $resp = $client->getOperationHours($library_id, $term_id, $date, $shorten); $str = $resp; } catch (\XML_RPC2_FaultException $e) { $errormsg = 'Fault Code: ' . $e->getFaultCode() . "\n"; $errormsg = 'Fault Reason: ' . $e->getFaultString() . "\n"; error_log($errormsg); } catch (\Exception $e) { error_log('Exception : ' . $e->getMessage()); } return $str; }
<?php error_reporting(0); require_once 'XML/RPC2/Client.php'; $email = "*****@*****.**"; $email = $_POST[email]; try { $client = XML_RPC2_Client::create("http://api.benchmarkemail.com/1.3/"); $token = $client->login("user", "pass"); $listID = "123abc"; $rec1['email'] = $email; $rec = array($rec1); $result = $client->listAddContacts($token, $listID, $rec); } catch (XML_RPC2_FaultException $e) { $er = "ERROR:" . $e->getFaultString() . "(" . $e->getFaultCode() . ")"; }
public function __construct($rpc_url) { $this->rpc = XML_RPC2_Client::create($rpc_url, array('prefix' => 'system.')); $this->_load(); }
protected function updateTicket($ticketId, $newStatus, $message, $resolution) { if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('XML/RPC2/Client.php')) { PHPUnit_Util_Filesystem::collectStart(); require_once 'XML/RPC2/Client.php'; $ticket = XML_RPC2_Client::create($this->scheme . '://' . $this->username . ':' . $this->password . '@' . $this->hostpath, array('prefix' => 'ticket.')); try { $ticketInfo = $ticket->get($ticketId); } catch (XML_RPC2_FaultException $e) { throw new PHPUnit_Framework_Exception(sprintf("Trac fetch failure: %d: %s\n", $e->getFaultCode(), $e->getFaultString())); } try { printf("Updating Trac ticket #%d, status: %s\n", $ticketId, $newStatus); $ticket->update($ticketId, $message, array('status' => $newStatus, 'resolution' => $resolution)); } catch (XML_RPC2_FaultException $e) { throw new PHPUnit_Framework_Exception(sprintf("Trac update failure: %d: %s\n", $e->getFaultCode(), $e->getFaultString())); } foreach (PHPUnit_Util_Filesystem::collectEnd() as $blacklistedFile) { PHPUnit_Util_Filter::addFileToFilter($blacklistedFile, 'PHPUNIT'); } } else { throw new PHPUnit_Framework_Exception('XML_RPC2 is not available.'); } }
public function remove($rpc_url) { $client = XML_RPC2_Client::create($rpc_url, array('prefix' => 'd.')); $return = $client->erase($this->getHash()); unset($this); }
<?php require_once 'XML/RPC2/Client.php'; $domain_api = XML_RPC2_Client::create('https://rpc.gandi.net/xmlrpc/', array('prefix' => 'domain.zone.', 'sslverify' => False)); $apikey = '<api_key>'; $zone_id = 1696666; $result = $domain_api->info($apikey, $zone_id); print_r($result);
/** * Posts a survey response to the remote server. But first * checks to make sure the current user is authorized to * post the survey. * * The params listed below are the items posted in $params. * @param $comment_id * @param $bullet_id * @param $bullet_rev * @param $survey_id An identifier for the survey being responded to * @param $response_id The answer to the response * @param $text Free form survey response (if relevant) * * @return Returns the response from the remote host. */ public function actionPostSurveyBullets( $params ) { $dbr = wfGetDB( DB_SLAVE ); global $wgUser; $user = $wgUser->getName(); $bulletID = $params['bullet_id']; $commentID = $params['comment_id']; $bulletRev = $params['bullet_rev']; $surveyID = $params['survey_id']; $responseID = $params['response_id']; $text = $params['text']; $comment = $dbr->selectRow( $table = 'thread', $vars = array( 'thread_author_name as user' ), $conds = 'thread_id = ' . $commentID ); $bullet = $dbr->selectRow( $table = 'reflect_bullet_revision', $vars = array( 'bl_user as user' ), $conds = 'bl_rev_id = ' . $bulletRev ); // only commenters can answer survey 2 // only bullet writers can answer survey 1 if ( ( $surveyID == "2" && $user != $comment->user ) || ( $surveyID == "1" && $user != $bullet->user ) ) { $resp = array( 'invalid post' ); // TODO: use dieUsageMsg instead } else { global $wgReflectStudyRPCHost, $wgReflectStudyDomain; // store hash of username on remote study server for anonymity $user = md5( $user ); $rpcConn = XML_RPC2_Client::create( $wgReflectStudyRPCHost, array( 'backend' => 'php' ) ); try { if ( !$text ) $text = ''; $resp = $rpcConn->post_survey_response( $wgReflectStudyDomain, $commentID, $bulletID, $bulletRev, $responseID, $surveyID, $user, $text ); } catch ( XML_RPC2_FaultException $e ) { // The XMLRPC server returns a XMLRPC error die( 'Exception #' . $e->getFaultCode() . ' : ' . $e->getFaultString() ); } catch ( Exception $e ) { // Other errors (HTTP or networking problems...) die( 'Exception : ' . $e->getMessage() ); } } $this->getResult()->addValue( null, $this->getModuleName(), $resp ); }
<th>Nummer</th> <th>Dato</th> <th>Name</th> <th>At betale</th> <th>Betalt</th> <th>Status</th> </tr> </thead> <tbody> <?php foreach ($debtors as $debtor) { ?> <?php $options = array('prefix' => 'shop.', 'encoding' => 'iso-8859-1', 'debug' => false); $client = XML_RPC2_Client::create('http://www.intraface.dk/xmlrpc/onlinepayment/server.php', $options); $info = $client->getPaymentTarget($credentials, $debtor['identifier_key']); ?> <tr> <td><?php echo $debtor['number']; ?> </td> <td><?php echo $debtor['description']; ?> </td> <td><?php echo $debtor['dk_this_date']; ?>
/** * Removes a collection from the database (including all of its documents and sub-collections). * * @param string $collectionName The full path to the collection. * @link http://exist-db.org/exist/apps/doc/devguide_xmlrpc.xml?id=D2.2.4#D2.2.4.8 */ public function removeCollection($collectionName) { $this->client->removeCollection($collectionName); }
/** * Create an XML_RPC2 client instance * * We use Php as backend, since xmlrpc encodes utf8 as html entity * * @param string $a_package Package name * @return */ public static function factory($a_package) { include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php'; $client = XML_RPC2_Client::create(ilRPCServerSettings::getInstance()->getServerUrl(), array('prefix' => $a_package . '.', 'encoding' => 'utf-8', 'backend' => 'Php', 'debug' => false)); return $client; }
function iaasImageList() { $apiConnect = XML_RPC2_Client::create('https://rpc.gandi.net/xmlrpc/', array('prefix' => 'hosting.', 'sslverify' => False)); $result = $apiConnect->__call('image.list', array(APIKEY)); return $result; }
} if ($protocol == "https" || $newvoucher['vouchersyncport'] == "443") { $url = "https://{$newvoucher['vouchersyncdbip']}"; } else { $url = "http://{$newvoucher['vouchersyncdbip']}"; } $url .= ":{$newvoucher['vouchersyncport']}/xmlrpc.php"; $execcmd = <<<EOF \t\t\t\t\$toreturn = array(); \t\t\t\t\$toreturn['voucher'] = \$config['voucher']['{$cpzone}']; \t\t\t\tunset(\$toreturn['vouchersyncport'], \$toreturn['vouchersyncpass'], \$toreturn['vouchersyncusername'], \$toreturn['vouchersyncdbip']); EOF; $options = array('prefix' => 'pfsense.', 'sslverify' => false, 'connectionTimeout' => 240); log_error(sprintf(gettext("voucher XMLRPC sync data %s"), $url)); $cli = XML_RPC2_Client::create($url, $options); if (!is_object($cli)) { $error = sprintf(gettext("A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with %s (pfsense.exec_php)."), $url); log_error($error); file_notice("sync_settings", $error, "Settings Sync", ""); $input_errors[] = $error; } else { try { $resp = $cli->exec_php($newvoucher['vouchersyncusername'], $newvoucher['vouchersyncpass'], $execcmd); } catch (XML_RPC2_FaultException $e) { // The XMLRPC server returns a XMLRPC error $error = 'Exception calling XMLRPC method exec_php #' . $e->getFaultCode() . ' : ' . $e->getFaultString(); log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", ""); $input_errors[] = $error; } catch (Exception $e) {
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); ini_set('error_reporting', E_ERROR); set_include_path('/usr/share/pear/sharelib/pear/' . PATH_SEPARATOR . get_include_path()); require "XML/RPC2/Client.php"; $options = array('prefix' => 'time.', 'debug' => true); $client = XML_RPC2_Client::create('http://stat.kupa.lan/trash/server.php', $options); $result = $client->hello('Sergio'); $factor = $client->factor(20); echo $result . '-' . $factor; // //$client = XML_RPC2_Client::create('http://stat.kupa.lan/trash/server.php',array('prefix'=>'system.','debug'=>true)); //$res = $client->listMethods(); //echo $res; ?>
/** * Construct a new XML_RPC2_Client PHP Backend. * * A URI must be provided (e.g. http://xmlrpc.example.com/1.0/). * Optionally, some options may be set. * * @param string URI for the XML-RPC server * @param array (optional) Associative array of options */ public function __construct($uri, $options = array()) { parent::__construct($uri, $options); }
function getClient() { return XML_RPC2_Client::create("http://{$this->host}:{$this->port}", $this->options); }
/** * Get a Trac XML_RPC2 client * * @return XML_RPC2_Client */ protected function getClient() { if (!PHPUnit_Util_Filesystem::fileExistsInIncludePath('XML/RPC2/Client.php')) { throw new PHPUnit_Framework_Exception('PEAR/XML_RPC2 is not available.'); } require_once 'XML/RPC2/Client.php'; $url = sprintf('%s://%s:%s@%s', $this->scheme, $this->username, $this->password, $this->hostpath); return XML_RPC2_Client::create($url, array('prefix' => 'ticket.')); }
/** * Use XML-RPC approach. * * @param string $prefix * @param string $method * @param array $parameters * @access protected * @return string * @throws Services_YouTube_Exception */ protected function useXMLRPC($prefix, $method, $parameters) { require_once 'XML/RPC2/Client.php'; $options = array('prefix' => $prefix); try { $client = XML_RPC2_Client::create('http://' . self::URL . self::XMLRPC_PATH, $options); $result = $client->{$method}($parameters); } catch (XML_RPC2_FaultException $e) { throw new Services_YouTube_Exception('XML_RPC Failed :' . $e->getMessage()); } catch (Exception $e) { throw new Services_YouTube_Exception($e->getMessage()); } return $result; }
#!/usr/bin/php # # PHP example to list all extensions currently in promotion at Gandi # Requirements: PEAR XML_RPC2 package # Reference: http://doc.rpc.gandi.net/catalog/reference.html # # Limitations: # - Will not find promotion on second level top level domain names. # Do to so, query the Catalog API directly with a FQDN. # <?php require_once 'XML/RPC2/Client.php'; // See http://doc.rpc.gandi.net/hosting/usage.html#connect-to-the-api-server $apikey = 'my 24-character API key'; $catalog_api = XML_RPC2_Client::create('https://rpc.gandi.net/xmlrpc/', array('prefix' => 'catalog.', 'sslverify' => False)); // Parameters for catalog.list() $query_parms = array("product" => array("type" => "domain"), "action" => array("duration" => 1, 'name' => 'create')); $currency = 'EUR'; $grid = 'A'; $result = $catalog_api->list($apikey, $query_parms, $currency, $grid); /* products which have a special catalog price have 'special_op' as 'true' as part of the additional unit_price array element in our result */ $promotions = array(); foreach ($result as $res) { // Necessary loop as 'special_op' isn't always the first array element. $has_promotion = false; foreach ($res['unit_price'] as $unit) { if ($unit['special_op'] == true) { $special_price = $unit['price']; $has_promotion = true; } else {
if (!function_exists("app_conf")) { //引入数据库的系统配置及定义配置函数 $sys_config = (require APP_ROOT_PATH . 'system/config.php'); function app_conf($name) { return stripslashes($GLOBALS['sys_config'][$name]); } } $options = array('prefix' => '1.5.', 'encoding' => 'utf-8', 'debug' => false); $api_url = 'http://api.lian-wo.com/'; # api地址,不需要更改 $username = app_conf("EDM_USERNAME"); # 您的账号 $password = app_conf("EDM_PASSWORD"); # 您的密码 $client = XML_RPC2_Client::create($api_url, $options); $token = $client->login($username, $password); //邮件地址 多个邮件地址用英文逗号隔开 //$email='test@gmail.com,test1@gmail.com'; function create_email($email, $client, $token) { try { $group_id = $client->createGroup($token, "easethink_" . time()); //指定所属组 $group = array($group_id); $email_id = $client->createEmail($token, $email, $group); return $group_id; } catch (XML_RPC2_FaultException $e) { // The XMLRPC server returns a XMLRPC error return 'Exception #' . $e->getFaultCode() . ' : ' . $e->getFaultString(); } catch (Exception $e) {
<?php require_once 'XML/RPC2/Client.php'; $apikey = '<api_key>'; // Image available list $api_hosting = XML_RPC2_Client::create('https://rpc.gandi.net/xmlrpc/', array('prefix' => 'hosting.image.', 'sslverify' => False)); $result = $api_hosting->list($apikey); print_r($result);
/** * Do the real call if no cache available * * NB : The '___' at the end of the method name is to avoid collisions with * XMLRPC __call() * * @param string Method name * @param array Parameters * @return mixed The call result, already decoded into native types */ private function _workWithoutCache___($methodName, $parameters) { if (!isset($this->_clientObject)) { // If the XML_RPC2_Client object is not available, let's build it require_once 'XML/RPC2/Client.php'; $this->_clientObject = XML_RPC2_Client::create($this->_uri, $this->_options); } // the real function call... return call_user_func_array(array($this->_clientObject, $methodName), $parameters); }
<?php require_once 'XML/RPC2/Client.php'; $apikey = '<api_key>'; // Mailbox $apiMailbox = XML_RPC2_Client::create('https://rpc.gandi.net/xmlrpc/', array('prefix' => 'domain.mailbox.', 'sslverify' => False)); $result = $apiMailbox->count($apikey, '<domain_name>'); print_r($result);
protected function getXmlRpcClient() { // Do we have a XML-RPC client already? If not, defaults to XML_RPC2 if (!isset($this->xmlrpc)) { $options = array('sslverify' => false); $this->setXmlRpcClient(XML_RPC2_Client::create($this->apiEndpoint, $options)); } return $this->xmlrpc; }