本文整理汇总了PHP中xmlrpc_client::setDebug方法的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpc_client::setDebug方法的具体用法?PHP xmlrpc_client::setDebug怎么用?PHP xmlrpc_client::setDebug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpc_client
的用法示例。
在下文中一共展示了xmlrpc_client::setDebug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->args = argParser::getArgs();
$this->client = new xmlrpc_client('/NOTEXIST.php', $this->args['LOCALSERVER'], 80);
$this->client->setDebug($this->args['DEBUG']);
if ($this->args['DEBUG'] == 1) {
ob_start();
}
}
示例2: 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;
}
示例3: 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;
}
示例4: setUp
public function setUp()
{
$this->args = argParser::getArgs();
$server = explode(':', $this->args['LOCALSERVER']);
if (count($server) > 1) {
$this->client = new xmlrpc_client($this->args['URI'], $server[0], $server[1]);
} else {
$this->client = new xmlrpc_client($this->args['URI'], $this->args['LOCALSERVER']);
}
$this->client->setDebug($this->args['DEBUG']);
$this->client->request_compression = $this->request_compression;
$this->client->accepted_compression = $this->accepted_compression;
$this->coverageScriptUrl = 'http://' . $this->args['LOCALSERVER'] . '/' . str_replace('/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['URI']);
if ($this->args['DEBUG'] == 1) {
ob_start();
}
}
示例5: params
function params($call)
{
if (isset($this->parms[$call])) {
$answer[0] = $this->parms[$call];
return $answer[0];
}
$msg = new xmlrpcmsg("system.methodSignature", array(php_xmlrpc_encode($call)));
$client = new xmlrpc_client($this->ServerURL);
$client->setDebug($this->DebugLevel);
$response = $client->send($msg);
$answer = php_xmlrpc_decode($response->value());
$this->parms[$call] = $answer[0];
return $answer[0];
}
示例6: call
function call($url, $method, $params)
{
// xmlrpc encode parameters
for ($i = 0; $i < count($params); $i++) {
if (get_class($params[$i]) != 'xmlrpcval') {
$params[$i] = xmlrpc_encoder($params[$i]);
}
}
// send request
$message = new xmlrpcmsg($method, $params);
if ($this->debug) {
// $this->display_xml($message->serialize());
print "<PRE>" . htmlentities($message->serialize()) . "</PRE>\n";
//("XML-RPC message:\n $message->serialize()",0);
}
$addr = parse_url($url);
$client = new xmlrpc_client($url, $addr['host'], $addr['port'], $this->connTimeout, $this->recvTimeout);
if ($this->debug) {
$client->setDebug(1);
}
debug("XML-RPC", "call to " . $url);
$response = $client->send($message);
if ($this->debug) {
print "<PRE>" . htmlentities($response->serialize()) . "</PRE>\n";
}
// process response
//debug("XML-RPC Response", $response->serialize());
if (!$response) {
addError("No response: probably host is unreachable");
} elseif ($response->faultCode() > 0) {
// there was an error
addError("Error response: " . $response->faultCode() . " " . $response->faultString());
} else {
$retval = $response->value();
if ($retval) {
$retval = xmlrpc_decoder($retval);
}
//debug("Response", $retval);
return $retval;
}
return NULL;
}
示例7: update
public function update()
{
global $config;
$host = $config['host'];
$port = $config['port'];
$user = $config['user'];
$passwd = $config['passwd'];
$f = new xmlrpcmsg("status", "");
//echo "<PRE>Sending the following request:<BR>" . htmlentities($f->serialize()) . "</PRE>\n";
$c = new xmlrpc_client("", $host, $port);
$c->setCredentials($user, $passwd);
$c->setDebug(0);
$r = $c->send($f);
if (!$r->faultCode()) {
//Got a valid result, decode into php variables
return php_xmlrpc_decode($r->value());
} else {
return array('code' => $r->faultCode(), 'reason' => $r->faultString());
}
}
示例8: planworld_xmlrpc_query
function planworld_xmlrpc_query($node, $message, $params, $debug = FALSE)
{
$nodeinfo = planworld_node_getinfo($node);
$f = new xmlrpcmsg($message);
// echo "<hr>";
foreach ($params as $param) {
if (is_int($param)) {
$type = "int";
}
if (is_string($param)) {
$type = "string";
}
if (is_array($param)) {
$type = "array";
if (!isset($param[count($param) - 1])) {
$type = "struct";
}
}
if (is_bool($param)) {
$type = xmlrpcBoolean;
}
$f->addParam(new xmlrpcval($param, $type));
//print_r($f);
//echo "$param : $type<br/>";
//echo "<hr>";
}
$c = new xmlrpc_client($nodeinfo["directory"], $nodeinfo["server"], $nodeinfo["port"]);
$c->setDebug(FALSE);
$r = $c->send($f);
if (!$r) {
$returnval = "<div class='alert'>{$message} to {$node} failed on send().</div>";
} else {
$v = $r->value();
if (!$r->faultCode()) {
if ($v->kindOf() == 'scalar') {
$returnval = $v->scalarval();
}
} else {
if ($debug) {
$returnval = "Fault: ";
$returnval .= "Code: " . $r->faultCode() . " Reason '" . $r->faultString() . "'<br/>";
}
}
}
return $returnval;
}
示例9: wrap_xmlrpc_method
/**
* Given an xmlrpc client and a method name, register a php wrapper function
* that will call it and return results using native php types for both
* params and results. The generated php function will return an xmlrpcresp
* oject for failed xmlrpc calls
*
* Known limitations:
* - server must support system.methodsignature for the wanted xmlrpc method
* - for methods that expose many signatures, only one can be picked (we
* could in priciple check if signatures differ only by number of params
* and not by type, but it would be more complication than we can spare time)
* - nested xmlrpc params: the caller of the generated php function has to
* encode on its own the params passed to the php function if these are structs
* or arrays whose (sub)members include values of type datetime or base64
*
* Notes: the connection properties of the given client will be copied
* and reused for the connection used during the call to the generated
* php function.
* Calling the generated php function 'might' be slow: a new xmlrpc client
* is created on every invocation and an xmlrpc-connection opened+closed.
* An extra 'debug' param is appended to param list of xmlrpc method, useful
* for debugging purposes.
*
* @param xmlrpc_client $client an xmlrpc client set up correctly to communicate with target server
* @param string $methodname the xmlrpc method to be mapped to a php function
* @param array $extra_options array of options that specify conversion details. valid ptions include
* integer signum the index of the method signature to use in mapping (if method exposes many sigs)
* integer timeout timeout (in secs) to be used when executing function/calling remote method
* string protocol 'http' (default), 'http11' or 'https'
* string new_function_name the name of php function to create. If unsepcified, lib will pick an appropriate name
* string return_source if true return php code w. function definition instead fo function name
* bool encode_php_objs let php objects be sent to server using the 'improved' xmlrpc notation, so server can deserialize them as php objects
* bool decode_php_objs --- WARNING !!! possible security hazard. only use it with trusted servers ---
* mixed return_on_fault a php value to be returned when the xmlrpc call fails/returns a fault response (by default the xmlrpcresp object is returned in this case). If a string is used, '%faultCode%' and '%faultString%' tokens will be substituted with actual error values
* bool debug set it to 1 or 2 to see debug results of querying server for method synopsis
* @return string the name of the generated php function (or false) - OR AN ARRAY...
*/
function wrap_xmlrpc_method($client, $methodname, $extra_options = 0, $timeout = 0, $protocol = '', $newfuncname = '')
{
// mind numbing: let caller use sane calling convention (as per javadoc, 3 params),
// OR the 2.0 calling convention (no options) - we really love backward compat, don't we?
if (!is_array($extra_options)) {
$signum = $extra_options;
$extra_options = array();
} else {
$signum = isset($extra_options['signum']) ? (int) $extra_options['signum'] : 0;
$timeout = isset($extra_options['timeout']) ? (int) $extra_options['timeout'] : 0;
$protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : '';
$newfuncname = isset($extra_options['new_function_name']) ? $extra_options['new_function_name'] : '';
}
//$encode_php_objects = in_array('encode_php_objects', $extra_options);
//$verbatim_client_copy = in_array('simple_client_copy', $extra_options) ? 1 :
// in_array('build_class_code', $extra_options) ? 2 : 0;
$encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool) $extra_options['encode_php_objs'] : false;
$decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool) $extra_options['decode_php_objs'] : false;
$simple_client_copy = isset($extra_options['simple_client_copy']) ? (int) $extra_options['simple_client_copy'] : 0;
$buildit = isset($extra_options['return_source']) ? !$extra_options['return_source'] : true;
$prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc';
if (isset($extra_options['return_on_fault'])) {
$decode_fault = true;
$fault_response = $extra_options['return_on_fault'];
} else {
$decode_fault = false;
$fault_response = '';
}
$debug = isset($extra_options['debug']) ? $extra_options['debug'] : 0;
$msgclass = $prefix . 'msg';
$valclass = $prefix . 'val';
$decodefunc = 'php_' . $prefix . '_decode';
$msg = new $msgclass('system.methodSignature');
$msg->addparam(new $valclass($methodname));
$client->setDebug($debug);
$response =& $client->send($msg, $timeout, $protocol);
if ($response->faultCode()) {
error_log('XML-RPC: could not retrieve method signature from remote server for method ' . $methodname);
return false;
} else {
$msig = $response->value();
if ($client->return_type != 'phpvals') {
$msig = $decodefunc($msig);
}
if (!is_array($msig) || count($msig) <= $signum) {
error_log('XML-RPC: could not retrieve method signature nr.' . $signum . ' from remote server for method ' . $methodname);
return false;
} else {
// pick a suitable name for the new function, avoiding collisions
if ($newfuncname != '') {
$xmlrpcfuncname = $newfuncname;
} else {
// take care to insure that methodname is translated to valid
// php function name
$xmlrpcfuncname = $prefix . '_' . preg_replace(array('/\\./', '/[^a-zA-Z0-9_\\x7f-\\xff]/'), array('_', ''), $methodname);
}
while ($buildit && function_exists($xmlrpcfuncname)) {
$xmlrpcfuncname .= 'x';
}
$msig = $msig[$signum];
$mdesc = '';
// if in 'offline' mode, get method description too.
// in online mode, favour speed of operation
//.........这里部分代码省略.........
示例10: list
function _send_xmlrpc_($method_name, $args, $url, $debug = True)
{
list($uri, $hostpart) = $this->_split_url($url);
if (gettype($args) != 'array') {
$arr[] = new xmlrpcval($args, 'string');
$f = new xmlrpcmsg($method_name, $arr, 'string');
} else {
while (list($key, $val) = @each($args)) {
if (gettype($val) == 'array') {
while (list($x, $y) = each($val)) {
$tmp[$x] = new xmlrpcval($y, 'string');
}
$ele[$key] = new xmlrpcval($tmp, 'struct');
} else {
$ele[$key] = new xmlrpcval($val, 'string');
}
}
$arr[] = new xmlrpcval($ele, 'struct');
$f = new xmlrpcmsg($method_name, $arr, 'struct');
}
$this->debug('<pre>' . htmlentities($f->serialize()) . '</pre>' . "\n", $debug);
$c = new xmlrpc_client($uri, $hostpart, 80);
$c->setCredentials($args['username'], $args['password']);
// _debug_array($c);
$c->setDebug(0);
$r = $c->send($f);
if (!$r) {
$this->debug('send failed');
}
$v = $r->value();
if (!$r->faultCode()) {
$this->debug('<hr>I got this value back<br><pre>' . htmlentities($r->serialize()) . '</pre><hr>', $debug);
$this->result = php_xmlrpc_decode($v);
} else {
$this->debug('Fault Code: ' . $r->faultCode() . ' Reason "' . $r->faultString() . '"<br>', $debug);
$this->result = htmlentities($r->serialize());
}
return $this->result;
}
示例11: xmlrpcmsg
*/
/**
* required setup
*/
require_once '../kernel/setup_inc.php';
require_once UTIL_PKG_PATH . 'xmlrpc/xmlrpc.inc';
require_once UTIL_PKG_PATH . 'xmlrpc/xmlrpcs.inc';
// EDIT FROM THIS LINE
$server_port = 80;
$server_uri = "localhost";
$server_path = XMLRPC_PKG_URL . "xmlrpc.php";
$username = 'admin';
$password = 'admin';
// DON'T EDIT BELOW THIS LINE
$client = new xmlrpc_client("{$server_path}", "{$server_uri}", $server_port);
$client->setDebug(1);
$appkey = '';
/*
$blogs=new xmlrpcmsg('blogger.newPost',array(new xmlrpcval($appkey,"string"),
new xmlrpcval("1","string"),
new xmlrpcval($username,"string"),
new xmlrpcval($password,"string"),
new xmlrpcval("pepe","string"),
new xmlrpcval(0,"boolean"),
));
*/
// Introspection mechanism
$blogs = new xmlrpcmsg('system.listMethods', "");
$result = $client->send($blogs);
if (!$result) {
$errorMsg = 'Cannot send message to server maybe the server is down';
示例12: dlfldigi_call
function dlfldigi_call($instance, $key, $value1 = null, $value2 = null)
{
global $dlfldigi_instances;
$message = new xmlrpcmsg($key);
// var_dump(is_int(intval($value1)), is_string($value1));
$type = "int";
if (in_array($key, array("main.set_wf_sideband", "modem.set_by_name", "rig.set_mode"))) {
$type = "string";
}
if (in_array($key, array("main.set_rsid", "main.set_afc"))) {
$type = "boolean";
}
if (in_array($key, array("rig.set_frequency"))) {
$type = "double";
}
if ($value1 !== false) {
if ($type == "boolean" && $value1 === "true") {
$value1 = true;
}
if ($type == "boolean" && $value1 === "false") {
$value1 = false;
}
$message->addParam(new xmlrpcval($value1, $type));
}
//if ($value2 !== false)
// $message->addParam(new xmlrpcval($value2, $type));
// error_log("dlfldigi_call($key, $value1, $value2)");
$xmlrpc_server = isset($dlfldigi_instances[$instance]) ? $dlfldigi_instances[$instance][0] : false;
$xmlrpc_port = isset($dlfldigi_instances[$instance]) ? $dlfldigi_instances[$instance][1] : false;
// error_log(print_r($dlfldigi_instances[$instance], true));
if (!$xmlrpc_server || !$xmlrpc_port) {
$err = "DL-XMLRPC: config for " . $instance . " not found!";
error_log($err);
return $err;
}
$c = new xmlrpc_client("/RPC2", $xmlrpc_server, $xmlrpc_port);
if (isset($_GET['dbg'])) {
$c->setDebug(1);
echo htmlentities($message->serialize());
}
$response =& $c->send($message);
if (!$response->faultCode()) {
$v = $response->value();
if (count($v->me)) {
//echo "me=" . print_r($v->me, true);
foreach ($v->me as $k => $item) {
//echo "$k=" . print_r($item, true);
// error_log($key . "=" . print_r($item, true));
return $item;
}
}
} else {
// ignore code 2
// Code: 2 Reason: 'Invalid return payload: enable debugging to examine incoming payload found not-xmlrpc xml element NIL'
if ($response->faultCode() != 2) {
$err = "DL-XMLRPC: " . "Code: " . $response->faultCode() . " Reason: '" . htmlspecialchars($response->faultString()) . "'";
if ($response->faultCode() == 5) {
$err .= " (" . $xmlrpc_server . ":" . $xmlrpc_port . ")";
}
//$err .= " (" . $key . ($value1 ? "=" . $value1 : ""). ")";
error_log($err);
if (isset($_GET['dbg'])) {
echo $err . "<br/>";
}
return $err . "\n";
}
}
}
示例13: do_call
include_once ".xmlrpc.inc.php";
// Define Server environment
// Server
// Production Server
// $client = new xmlrpc_client("/tr_xmlrpc.cgi", "apibugzilla.novell.com", 443, "https");
// Testserver
$client = new xmlrpc_client("/tr_xmlrpc.cgi", "apibugzillastage.provo.novell.com", 443, "https");
// Username and Password (Must be defined in calling script)
// $username = "";
// $password = "";
$client->setCredentials($username, $password);
// SSL Verify Peer
// $client->setSSLVerifyPeer(FALSE);
$client->setSSLVerifyPeer(TRUE);
// Debug on/off
$client->setDebug(0);
// Functions
function do_call($call)
{
global $client;
// Do call and handle feedback
if (!($res = $client->send($call))) {
print "Could not connect to HTTPS server.";
return FALSE;
}
if ($res->faultCode() == 0) {
$value = $res->value();
return php_xmlrpc_decode($value);
} else {
print "XML-RPC Fault #" . $res->faultCode() . ": " . $res->faultString();
return FALSE;
示例14: plan_read_xmlrpc
function plan_read_xmlrpc($remoteuser = 'bob', $remotenode = '@note')
{
if ($nodeinfo = planworld_node_getinfo($remotenode)) {
if ($_SERVER['USERINFO_ARRAY']['snitchlevel']) {
$snitch = 1;
}
if (!$_SERVER['USER'] || $_SERVER['USER'] == 'guest') {
output('unauthorized', "you can't read offsite plans if you're not logged in.");
exit;
}
$f = new xmlrpcmsg('planworld.plan.getContent');
$f->addParam(new xmlrpcval($remoteuser, "string"));
$f->addParam(new xmlrpcval($_SERVER['USER'] . "@planwatch.org", "string"));
$f->addParam(new xmlrpcval($snitch, "boolean"));
$c = new xmlrpc_client($nodeinfo["directory"], $nodeinfo["server"], $nodeinfo["port"]);
$c->setDebug(0);
$r = $c->send($f);
if (!$r) {
$plan = "<div class='alert'>Could not retrieve {$remoteuser}'s plan from {$nodeinfo['server']}.</div>";
} else {
$v = $r->value();
if (!$r->faultCode()) {
if ($v->kindOf() == 'scalar') {
$plan = WrapWords($v->scalarval(), 80);
}
} else {
$plan = "Fault: ";
$plan .= "Code: " . $r->faultCode() . " Reason '" . $r->faultString() . "'<br/>";
}
}
} else {
$plan = plan_read_finger($remoteuser . $remotenode);
}
if (strstr($plan, 'plan is not available')) {
$plan = "{$remoteuser}@{$remotenode} does not allow plan reads outside {$nodeinfo['server']}.<br />You can still <a href='/send/{$remoteuser}{$remotenode}'>send a message</a> if you want to establish contact.";
}
return $plan;
}
示例15: xmlrpcmsg
if (!$r) {
print "<PRE>ERROR: couldn't send message</PRE>\n";
return 0;
} else {
if (!$r->faultCode()) {
return $r->value();
} else {
print "Fault: ";
print "Code: " . $r->faultCode() . " Reason '" . $r->faultString() . "'<BR>";
return 0;
}
}
}
$f = new xmlrpcmsg('system.listMethods');
$c = new xmlrpc_client("/server.php", "xmlrpc.heddley.com", 80);
$c->setDebug(0);
$v = rpc_call($c, $f);
print "<h2>methods available at http://" . $c->server . ":" . $c->port . $c->path . "</h2>\n";
if ($v) {
for ($i = 0; $i < $v->arraysize(); $i++) {
$mname = $v->arraymem($i);
print "<H3>" . $mname->scalarval() . "</H3>\n";
$f = new xmlrpcmsg('system.methodHelp');
$f->addParam(new xmlrpcval($mname->scalarval(), "string"));
$w = rpc_call($c, $f);
if ($w) {
$txt = $w->scalarval();
if ($txt != "") {
print "<H4>Documentation</H4><P>{$txt}</P>\n";
} else {
print "<P>No documentation available.</P>\n";