本文整理汇总了PHP中xmlrpc_client类的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpc_client类的具体用法?PHP xmlrpc_client怎么用?PHP xmlrpc_client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了xmlrpc_client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callRemote
function callRemote($method)
{
// Curl is required so generate a fault if curl functions cannot be found.
if (!$this->curl) {
return array('faultCode' => -1, 'faultString' => 'Curl functions are unavailable.');
}
// The first argument will always be the method name while all remaining arguments need
// to be passed along with the call.
$args = func_get_args();
array_shift($args);
if ($this->xmlrpc) {
// If php has xmlrpc support use the built in functions.
$request = xmlrpc_encode_request($method, $args);
$result = $this->__xmlrpc_call($request);
$decodedResult = xmlrpc_decode($result);
} else {
// If no xmlrpc support is found, use the phpxmlrpc library. This involves containing
// all variables inside the xmlrpcval class.
$encapArgs = array();
foreach ($args as $arg) {
$encapArgs[] = $this->__phpxmlrpc_encapsulate($arg);
}
$msg = new xmlrpcmsg($method, $encapArgs);
$client = new xmlrpc_client($this->url);
$client->verifypeer = false;
$result = $client->send($msg);
if ($result->errno) {
$decodedResult = array('faultCode' => $result->errno, 'faultString' => $result->errstr);
} else {
$decodedResult = php_xmlrpc_decode($result->value());
}
}
return $decodedResult;
}
示例2: connect
function connect()
{
global $oerpuser, $oerppwd, $dbname, $server_url, $client;
if (isset($_COOKIE["user_id"]) == true) {
if ($_COOKIE["user_id"] > 0) {
return $_COOKIE["user_id"];
}
}
try {
$sock = new xmlrpc_client($server_url . 'common');
$msg = new xmlrpcmsg('login');
$msg->addParam(new xmlrpcval($dbname, "string"));
$msg->addParam(new xmlrpcval($oerpuser, "string"));
$msg->addParam(new xmlrpcval($oerppwd, "string"));
$resp = $sock->send($msg);
$val = $resp->value();
$id = $val->scalarval();
} catch (Exception $ex) {
print "Unable to authenticate to openERP " . $ex->getMessage() . "\n";
}
setcookie("user_id", $id, time() + 3600);
if ($id > 0) {
return $id;
} else {
return -1;
}
}
示例3: phpAds_checkForUpdates
function phpAds_checkForUpdates($already_seen = 0, $send_sw_data = true)
{
global $phpAds_config, $phpAds_updatesServer;
global $xmlrpcerruser;
// Create client object
$client = new xmlrpc_client($phpAds_updatesServer['script'], $phpAds_updatesServer['host'], $phpAds_updatesServer['port']);
$params = array(new xmlrpcval($GLOBALS['phpAds_productname'], "string"), new xmlrpcval($phpAds_config['config_version'], "string"), new xmlrpcval($already_seen, "string"), new xmlrpcval($phpAds_config['updates_dev_builds'] ? 'dev' : '', "string"), new xmlrpcval($phpAds_config['instance_id'], "string"));
if ($send_sw_data) {
// Prepare software data
$params[] = phpAds_xmlrpcEncode(array('os_type' => php_uname('s'), 'os_version' => php_uname('r'), 'webserver_type' => isset($_SERVER['SERVER_SOFTWARE']) ? preg_replace('#^(.*?)/.*$#', '$1', $_SERVER['SERVER_SOFTWARE']) : '', 'webserver_version' => isset($_SERVER['SERVER_SOFTWARE']) ? preg_replace('#^.*?/(.*?)(?: .*)?$#', '$1', $_SERVER['SERVER_SOFTWARE']) : '', 'db_type' => $GLOBALS['phpAds_dbmsname'], 'db_version' => phpAds_dbResult(phpAds_dbQuery("SELECT VERSION()"), 0, 0), 'php_version' => phpversion(), 'php_sapi' => ucfirst(php_sapi_name()), 'php_extensions' => get_loaded_extensions(), 'php_register_globals' => (bool) ini_get('register_globals'), 'php_magic_quotes_gpc' => (bool) ini_get('magic_quotes_gpc'), 'php_safe_mode' => (bool) ini_get('safe_mode'), 'php_open_basedir' => (bool) strlen(ini_get('open_basedir')), 'php_upload_tmp_readable' => (bool) is_readable(ini_get('upload_tmp_dir') . DIRECTORY_SEPARATOR)));
}
// Create XML-RPC request message
$msg = new xmlrpcmsg("Openads.Sync", $params);
// Send XML-RPC request message
if ($response = $client->send($msg, 10)) {
// XML-RPC server found, now checking for errors
if (!$response->faultCode()) {
$ret = array(0, phpAds_xmlrpcDecode($response->value()));
// Prepare cache
$cache = $ret[1];
} else {
$ret = array($response->faultCode(), $response->faultString());
// Prepare cache
$cache = false;
}
// Save to cache
phpAds_dbQuery("\n\t\t\tUPDATE\n\t\t\t\t" . $phpAds_config['tbl_config'] . "\n\t\t\tSET\n\t\t\t\tupdates_cache = '" . addslashes(serialize($cache)) . "',\n\t\t\t\tupdates_timestamp = " . time() . "\n\t\t");
return $ret;
}
return array(-1, 'No response from the server');
}
示例4: um_xml_rpc_client_call
function um_xml_rpc_client_call($server_host, $server_path, $server_port, $proxy, $proxy_port, $proxy_user, $proxy_pass, $function, $parameters)
{
$msg = new xmlrpcmsg($function, $parameters);
$client = new xmlrpc_client($server_path, $server_host, $server_port);
$client->setProxy($proxy, $proxy_port, $proxy_user, $proxy_pass);
if (defined('XMLRPC_DEBUG')) {
$client->setDebug(XMLRPC_DEBUG);
}
$result = $client->send($msg, XMLRPC_TIMEOUT, '');
if (!$result) {
trigger_error('<strong>Open Update Manager</strong> Server comunication error. ' . $client->errstr);
return 0;
}
switch ($result->faultCode()) {
case 0:
break;
case 5:
trigger_error('<strong>Open Update Manager</strong> Server comunication error. ' . $result->faultString());
return 0;
default:
trigger_error('<strong>Open Update Manager</strong> XML-RPC error. ' . $result->faultString());
return 0;
}
return $result;
}
示例5: GetMultiRequest_XmlRpc_Lib
function GetMultiRequest_XmlRpc_Lib($host, $port, $passwd, $requestarr)
{
global $ConnectTimeout;
$c = new xmlrpc_client('xmlrpc', $host, $port);
$c->setCredentials('nzbget', $passwd);
$c->setDebug(False);
$farr = array();
foreach ($requestarr as $request) {
$f = new xmlrpcmsg($request[0], ParamsLIB($request[1]));
$farr[] = $f;
}
$ra = $c->multicall($farr, $ConnectTimeout);
$rarr = array();
$index = 0;
foreach ($ra as $r) {
if (!$r->faultCode()) {
//Got a valid result, decode into php variables
$rarr[] = php_xmlrpc_decode($r->value());
} else {
if (!strncmp($r->faultString(), 'Connect error: ', 15)) {
return 'ERROR: ' . $r->faultString();
}
trigger_error('RPC: method "' . $requestarr[$index][0] . '", error ' . $r->faultCode() . ' - ' . $r->faultString());
}
$index++;
}
return $rarr;
}
示例6: _serv
function _serv()
{
global $wbhost;
$server = new xmlrpc_client($wbhost);
$server->setSSLVerifyPeer(0);
return $server;
}
示例7: pingWeblogs
function pingWeblogs($name, $url, $server)
{
global $Paths;
if (strpos($server, "http://") === false) {
$server = "http://" . $server;
}
$server = parse_url($server);
if ($server['path'] == "") {
$server['path'] = "/";
}
if ($server['port'] == "") {
$server['port'] = "80";
}
printf("<p><b>%s:%s%s</b>:<br />", $server['host'], $server['port'], $server['path']);
flush();
$client = new xmlrpc_client($server['path'], $server['host'], $server['port']);
$message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($name), new xmlrpcval($url)));
$result = $client->send($message);
if (!$result || $result->faultCode()) {
echo "<br />Pivot says: could not send ping. Check if you set the server address correctly, or else the server may be temporarily down. This happens sometimes, and if this error occurs out of the blue, it's likely that it will go away in a few hours or days. <br /></p>";
echo "<!-- \n";
print_r($result);
echo "\n -->\n\n\n";
return false;
}
$msg = $result->serialize();
$msg = preg_replace('#.*<name>message</name>[^<]*<value>(.*?)</value>.*#si', '$1', $msg);
// Stripping off any tags in the message value - typically the string element
$msg = strip_tags($msg);
$msg = escape($msg);
echo "Server said: <i>'{$msg}'</i><br /></p>";
return true;
}
示例8: getClientConnect
public function getClientConnect()
{
$client = new xmlrpc_client(self::$odoo_url . ":" . self::$odoo_port . "/xmlrpc/object");
$client->setSSLVerifyPeer(0);
$client->setSSLVerifyHost(0);
return $client;
}
示例9: xmlrpcCall
function xmlrpcCall($url, $method, $params)
{
// xmlrpc encode parameters
for ($i = 0; $i < count($params); $i++) {
if (get_class($params[$i]) != 'xmlrpcval') {
$params[$i] = xmlrpc_encode($params[$i]);
}
}
// send request
$message = new xmlrpcmsg($method, $params);
debug("XML-RPC message", $message->serialize());
$addr = parse_url($url);
$client = new xmlrpc_client($url, $addr['host'], $addr['port']);
//if($debug)
// $client->setDebug(1);
debug("XML-RPC", "call to " . $url);
$response = $client->send($message);
// process response
debug("XML-RPC Response", $response->serialize());
if (!$response) {
debug("No response", "probably host is unreachable");
} elseif ($response->faultCode() != 0) {
// there was an error
debug("Error response: ", $response->faultCode() . " " . $response->faultString());
} else {
$retval = $response->value();
if ($retval) {
$retval = xmlrpc_decode($retval);
}
debug("Response", $retval);
return $retval;
}
return NULL;
}
示例10: SendRPC
/**
* Compiles and sends the Shopatron RPC
* @param Varien_Event_Observer $observer
* @return MikeRoyer_Shopatron_Model_Observer
*/
public function SendRPC($observer)
{
$server = new xmlrpc_client('/xmlServer.php', 'www.shopatron.com', 80);
$message = $this->compileRPC();
$result = $server->send($message);
// For secure transmission -- did not work for me
// $result = $server->send($message, 30, 'https');
$this->DoResult($result, $message);
}
示例11: __construct
function __construct($server)
{
$url = $server->host;
$pass = $server->getPass();
$db = new xmlrpc_client('xmlrpc.cgi', $url, 10000, 'http');
$db->setCredentials('root', $pass);
$db->return_type = 'phpvals';
$this->db = $db;
$this->sid = \Base::instance()->hash($url);
}
示例12: ItemSendPing
/**
* Ping the pingomatic RPC service.
*/
function ItemSendPing(&$params)
{
global $debug;
$item_Blog = $params['Item']->get_Blog();
$client = new xmlrpc_client('/', 'rpc.pingomatic.com', 80);
$client->debug = $debug && $params['display'];
$message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($item_Blog->get('name')), new xmlrpcval($item_Blog->get('url'))));
$result = $client->send($message);
$params['xmlrpcresp'] = $result;
return true;
}
示例13: send_message
function send_message($name, $params, $url)
{
$msg = new xmlrpcmsg($name, $params);
$client = new xmlrpc_client($url);
$client->return_type = 'phpvals';
$result = $client->send($msg);
if (!$result->faultCode()) {
return $result->value();
} else {
throw new SilkXmlRpcException($result->faultString(), $result->faultCode());
}
}
示例14: ItemSendPing
/**
* Ping the b2evonet RPC service.
*/
function ItemSendPing(&$params)
{
global $evonetsrv_host, $evonetsrv_port, $evonetsrv_uri;
global $debug, $baseurl, $instance_name;
$item_Blog = $params['Item']->get_Blog();
$client = new xmlrpc_client($evonetsrv_uri, $evonetsrv_host, $evonetsrv_port);
$client->debug = $debug == 2;
$message = new xmlrpcmsg('b2evo.ping', array(new xmlrpcval($item_Blog->ID), new xmlrpcval($baseurl), new xmlrpcval($instance_name), new xmlrpcval($item_Blog->dget('name', 'xml')), new xmlrpcval($item_Blog->dget('url', 'xml')), new xmlrpcval($item_Blog->dget('locale', 'xml')), new xmlrpcval($params['Item']->dget('title', 'xml'))));
$result = $client->send($message);
$params['xmlrpcresp'] = $result;
return true;
}
示例15: updateFile
public function updateFile($file)
{
$this->listHoruxGuiFile(".");
$client = new xmlrpc_client("http://www.horux.ch/update/xml_rpc_update.php");
$message = new xmlrpcmsg("getFile", array(new xmlrpcval($file, 'string'), new xmlrpcval("1.0", 'string')));
$resp = $client->send($message);
if ($resp->faultCode()) {
return false;
} else {
$value = $resp->value();
return base64_decode($value->scalarval());
}
}