本文整理汇总了PHP中xmlrpcmsg::serialize方法的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpcmsg::serialize方法的具体用法?PHP xmlrpcmsg::serialize怎么用?PHP xmlrpcmsg::serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpcmsg
的用法示例。
在下文中一共展示了xmlrpcmsg::serialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: gFaultXmlRequest
function gFaultXmlRequest($faultCode, $faultString)
{
global $stylevar;
$faultMethod = 'return_fault';
$xml = new xmlrpcmsg($faultMethod);
$xml->addParam($faultCode);
$xml->addParam($faultString);
$rxml = $xml->serialize($stylevar['charset']);
return $rxml;
}
示例3: forward_request
/**
* Forward an xmlrpc request to another server, and return to client the response received.
* @param xmlrpcmsg $m (see method docs below for a description of the expected parameters)
* @return xmlrpcresp
*/
function forward_request($m)
{
// create client
$timeout = 0;
$url = php_xmlrpc_decode($m->getParam(0));
$c = new xmlrpc_client($url);
if ($m->getNumParams() > 3) {
// we have to set some options onto the client.
// Note that if we do not untaint the received values, warnings might be generated...
$options = php_xmlrpc_decode($m->getParam(3));
foreach ($options as $key => $val) {
switch ($key) {
case 'Cookie':
break;
case 'Credentials':
break;
case 'RequestCompression':
$c->setRequestCompression($val);
break;
case 'SSLVerifyHost':
$c->setSSLVerifyHost($val);
break;
case 'SSLVerifyPeer':
$c->setSSLVerifyPeer($val);
break;
case 'Timeout':
$timeout = (int) $val;
break;
}
// switch
}
}
// build call for remote server
/// @todo find a weay to forward client info (such as IP) to server, either
/// - as xml comments in the payload, or
/// - using std http header conventions, such as X-forwarded-for...
$method = php_xmlrpc_decode($m->getParam(1));
$pars = $m->getParam(2);
$m = new xmlrpcmsg($method);
for ($i = 0; $i < $pars->arraySize(); $i++) {
$m->addParam($pars->arraymem($i));
}
// add debug info into response we give back to caller
xmlrpc_debugmsg("Sending to server {$url} the payload: " . $m->serialize());
return $c->send($m, $timeout);
}
示例4: 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;
}
示例5: htmlspecialchars
while (list($key, $val) = each($inAr)) {
print $key . ", " . $val . "\n";
}
// create parameters from the input array
$p = array();
reset($inAr);
while (list($key, $val) = each($inAr)) {
$p[] = new xmlrpcval(array("name" => new xmlrpcval($key), "age" => new xmlrpcval($val, "int")), "struct");
}
$v = new xmlrpcval($p, "array");
// print "Output values look like this: <PRE>\n" . htmlentities($v->serialize()). "</PRE>\n";
$f = new xmlrpcmsg('examples.sortByAge', array($v));
$c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
$c->setDebug(1);
print "\nAnd I sent\n\n";
print htmlspecialchars($f->serialize());
print "</PRE>";
print "Sending request...<BR>\n";
$r = $c->send($f);
//if (!$r) { die("send failed"); }
$v = $r->value();
if (!$r->faultCode()) {
print "The server gave me these results:<PRE>";
$max = $v->arraysize();
for ($i = 0; $i < $max; $i++) {
$rec = $v->arraymem($i);
$n = $rec->structmem("name");
$a = $rec->structmem("age");
print htmlspecialchars($n->scalarval()) . ", " . htmlspecialchars($a->scalarval()) . "\n";
}
print "<PRE><HR>For nerds: I got this value back<BR><PRE>" . htmlentities($r->serialize()) . "</PRE><HR>\n";
示例6: post_to_lj
function post_to_lj($id)
{
// get text for posting
$result = mysql_query("select l.name, l.description, l.additional_description, l.image, b.name as artist from wp_product_list as l, wp_product_brands as b where l.id='{$id}' and l.brand = b.id");
$row = mysql_fetch_array($result);
$_artist = $row['artist'];
$_title = nl2br(stripslashes($row['name']));
$_description = nl2br(stripslashes($row['description']));
$_additional_description = nl2br(stripslashes($row['additional_description']));
$_image = $row['image'];
$subj = "";
$text = $_artist . ': «' . $_title . '» ' . ' http://cartoonbank.ru/?page_id=29&cartoonid=' . $id . ' ' . $_description . "<br />Тэги: " . $_additional_description;
/* ваш ник в ЖЖ */
$name = "_cartoonist_";
/* ваш пароль в ЖЖ */
$password = "basie5670659";
/* текст который вы хотите опубликовать */
//$text = $body; //"Некоторый текст";
/* заголовок для текста */
//$subj = $subj; //"заголовок";
/* включаем библиотеку XML-RPC */
include "lib/xmlrpc.inc";
/* (!!!) Все данные в ЖЖ хранятся в кодировке Unicode,
используем и в нашем случае такую же кодировку */
$xmlrpc_internalencoding = 'UTF-8';
/* Получаем текущее время */
$date = time();
$year = date("Y", $date);
$mon = date("m", $date);
$day = date("d", $date);
$hour = date("G", $date);
$min = date("i", $date);
/* (!!!) Конвертируем текст из одной кодировки в UTF-8
в данном случае файл хранится в кодировке CP1251 */
//$text = iconv("CP1251", "UTF-8", html_entity_decode($text));
//$subj = iconv("CP1251", "UTF-8", html_entity_decode($subj));
/* заполняем массив с необходимыми переменными */
$post = array("username" => new xmlrpcval($name, "string"), "password" => new xmlrpcval($password, "string"), "event" => new xmlrpcval($text, "string"), "subject" => new xmlrpcval($subj, "string"), "lineendings" => new xmlrpcval("unix", "string"), "year" => new xmlrpcval($year, "int"), "mon" => new xmlrpcval($mon, "int"), "day" => new xmlrpcval($day, "int"), "hour" => new xmlrpcval($hour, "int"), "min" => new xmlrpcval($min, "int"), "ver" => new xmlrpcval(2, "int"));
/* на основе массива создаем структуру */
$post2 = array(new xmlrpcval($post, "struct"));
/* создаем XML сообщение для сервера */
$f = new xmlrpcmsg('LJ.XMLRPC.postevent', $post2);
/* описываем сервер */
$c = new xmlrpc_client("/interface/xmlrpc", "www.livejournal.com", 80);
$c->request_charset_encoding = "UTF-8";
/* по желанию смотрим на XML-код того что отправится на сервер */
echo nl2br(htmlentities($f->serialize()));
/* отправляем XML сообщение на сервер */
$r = $c->send($f);
/* анализируем результат */
if (!$r->faultCode()) {
/* сообщение принято успешно и вернулся XML-результат */
$v = php_xmlrpc_decode($r->value());
print_r($v);
} else {
/* сервер вернул ошибку */
print "An error occurred: ";
print "Code: " . htmlspecialchars($r->faultCode());
print "Reason: '" . htmlspecialchars($r->faultString()) . "'\n";
}
}
示例7: 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";
}
}
}
示例8: testAutoCoDec
function testAutoCoDec()
{
$data1 = array(1, 1.0, 'hello world', true, '20051021T23:43:00', -1, 11.0, '~!@#$%^&*()_+|', false, '20051021T23:43:00');
$data2 = array('zero' => $data1, 'one' => $data1, 'two' => $data1, 'three' => $data1, 'four' => $data1, 'five' => $data1, 'six' => $data1, 'seven' => $data1, 'eight' => $data1, 'nine' => $data1);
$data = array($data2, $data2, $data2, $data2, $data2, $data2, $data2, $data2, $data2, $data2);
//$keys = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
$v1 = php_xmlrpc_encode($data, array('auto_dates'));
$v2 = php_xmlrpc_decode_xml($v1->serialize());
$this->assertEquals($v1, $v2);
$r1 = new xmlrpcresp($v1);
$r2 = php_xmlrpc_decode_xml($r1->serialize());
$r2->serialize();
// needed to set internal member payload
$this->assertEquals($r1, $r2);
$m1 = new xmlrpcmsg('hello dolly', array($v1));
$m2 = php_xmlrpc_decode_xml($m1->serialize());
$m2->serialize();
// needed to set internal member payload
$this->assertEquals($m1, $m2);
}
示例9: 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;
}
示例10: xmlrpcmsg
if (isset($_GET['welcome'])) {
include TT_ROOT . 'smartbanner/app.php';
exit;
}
require_once './lib/xmlrpc.inc';
require_once './lib/xmlrpcs.inc';
require_once './xmlrpcs.php';
require_once './server_define.php';
require_once './mobiquo_common.php';
require_once './input.php';
require_once './xmlrpcresp.php';
require_once './env_setting.php';
if (isset($_POST['session']) && isset($_POST['api_key']) && isset($_POST['subject']) && isset($_POST['body']) || isset($_POST['email_target'])) {
require_once TT_ROOT . 'include/invitation.php';
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
require 'web.php';
exit;
}
$rpcServer = new Tapatalk_xmlrpcs($server_param, false);
$rpcServer->setDebug(1);
$rpcServer->compress_response = 'true';
$rpcServer->response_charset_encoding = 'UTF-8';
if (!empty($_POST['method_name'])) {
$xml = new xmlrpcmsg($_POST['method_name']);
$request = $xml->serialize();
$response = $rpcServer->service($request);
} else {
$response = $rpcServer->service();
}
exit;
示例11: nl2br
$day = date("d", $date);
$hour = date("G", $date);
$min = date("i", $date);
/* (!!!) Конвертируем текст из одной кодировки в UTF-8
в данном случае файл хранится в кодировке CP1251 */
//$text = iconv("CP1251", "UTF-8", html_entity_decode($text));
//$subj = iconv("CP1251", "UTF-8", html_entity_decode($subj));
/* заполняем массив с необходимыми переменными */
$post = array("username" => new xmlrpcval($name, "string"), "password" => new xmlrpcval($password, "string"), "event" => new xmlrpcval($text, "string"), "subject" => new xmlrpcval($subj, "string"), "lineendings" => new xmlrpcval("unix", "string"), "year" => new xmlrpcval($year, "int"), "mon" => new xmlrpcval($mon, "int"), "day" => new xmlrpcval($day, "int"), "hour" => new xmlrpcval($hour, "int"), "min" => new xmlrpcval($min, "int"), "ver" => new xmlrpcval(2, "int"));
/* на основе массива создаем структуру */
$post2 = array(new xmlrpcval($post, "struct"));
/* создаем XML сообщение для сервера */
$f = new xmlrpcmsg('LJ.XMLRPC.postevent', $post2);
/* описываем сервер */
$c = new xmlrpc_client("/interface/xmlrpc", "www.livejournal.com", 80);
$c->request_charset_encoding = "UTF-8";
/* по желанию смотрим на XML-код того что отправится на сервер */
echo nl2br(htmlentities($f->serialize()));
/* отправляем XML сообщение на сервер */
$r = $c->send($f);
/* анализируем результат */
if (!$r->faultCode()) {
/* сообщение принято успешно и вернулся XML-результат */
$v = php_xmlrpc_decode($r->value());
print_r($v);
} else {
/* сервер вернул ошибку */
print "An error occurred: ";
print "Code: " . htmlspecialchars($r->faultCode());
print "Reason: '" . htmlspecialchars($r->faultString()) . "'\n";
}
示例12: xmlrpcmsg
<html>
<head><title>zope test</title></head>
<body>
<?php
include "xmlrpc.inc";
$f = new xmlrpcmsg('document_src', array());
print "<PRE>\n" . htmlspecialchars($f->serialize()) . "</PRE>";
$c = new xmlrpc_client("/index_html", "pingu.heddley.com", 9080);
$c->setCredentials("username", "password");
$c->setDebug(1);
$r = $c->send($f);
if (!$r) {
die("send failed");
}
$v = $r->value();
if (!$r->faultCode()) {
print "I received:" . $v->scalarval() . "<BR>";
print "<HR>I got this value back<BR><PRE>" . htmlentities($r->serialize()) . "</PRE><HR>\n";
} else {
print "Fault: ";
print "Code: " . $r->faultCode() . " Reason '" . $r->faultString() . "'<BR>";
}
?>
</body>
</html>
示例13: xmlrpcmsg
<html>
<head><title>xmlrpc</title></head>
<body>
<?php
include "xmlrpc.inc";
// Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off
if (!isset($HTTP_POST_VARS) && isset($_POST)) {
$HTTP_POST_VARS = $_POST;
}
if (isset($HTTP_POST_VARS["stateno"]) && $HTTP_POST_VARS["stateno"] != "") {
$stateno = $HTTP_POST_VARS["stateno"];
$f = new xmlrpcmsg('examples.getStateName', array(new xmlrpcval($stateno, "int")));
print "<PRE>Sending the following request:<BR>" . htmlentities($f->serialize()) . "</PRE>\n";
$c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
$c->setDebug(1);
$r = $c->send($f);
$v = $r->value();
if (!$r->faultCode()) {
print "State number " . htmlspecialchars($stateno) . " is " . htmlspecialchars($v->scalarval()) . "<BR>";
// print "<HR>I got this value back<BR><PRE>" .
// htmlentities($r->serialize()). "</PRE><HR>\n";
} else {
print "Fault: ";
print "Code: " . htmlspecialchars($r->faultCode()) . " Reason '" . htmlspecialchars($r->faultString()) . "'<BR>";
}
} else {
$stateno = "";
}
print "<FORM ACTION=\"client.php\" METHOD=\"POST\">\n<INPUT NAME=\"stateno\" VALUE=\"" . htmlspecialchars($stateno) . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></FORM><P>\nenter a state number to query its name";
?>
</body>
示例14: xmlrpcmsg
<html>
<head><title>xmlrpc</title></head>
<body>
<h1>Getstatename demo</h1>
<h2>Send a U.S. state number to the server and get back the state name</h2>
<h3>The code demonstrates usage of the php_xmlrpc_encode function</h3>
<?php
include "xmlrpc.inc";
// Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off
if (!isset($HTTP_POST_VARS) && isset($_POST)) {
$HTTP_POST_VARS = $_POST;
}
if (isset($HTTP_POST_VARS["stateno"]) && $HTTP_POST_VARS["stateno"] != "") {
$stateno = (int) $HTTP_POST_VARS["stateno"];
$f = new xmlrpcmsg('examples.getStateName', array(php_xmlrpc_encode($stateno)));
print "<pre>Sending the following request:\n\n" . htmlentities($f->serialize()) . "\n\nDebug info of server data follows...\n\n";
$c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
$c->setDebug(1);
$r =& $c->send($f);
if (!$r->faultCode()) {
$v = $r->value();
print "</pre><br/>State number " . $stateno . " is " . htmlspecialchars($v->scalarval()) . "<br/>";
// print "<HR>I got this value back<BR><PRE>" .
// htmlentities($r->serialize()). "</PRE><HR>\n";
} else {
print "An error occurred: ";
print "Code: " . htmlspecialchars($r->faultCode()) . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>";
}
} else {
$stateno = "";
}
示例15: xmlrpcmsg
<html>
<head><title>xmlrpc</title></head>
<body>
<?php
include "xmlrpc.inc";
if ($HTTP_POST_VARS["stateno"] != "") {
$f = new xmlrpcmsg('examples.getStateName', array(new xmlrpcval($HTTP_POST_VARS["stateno"], "int")));
print "<pre>" . htmlentities($f->serialize()) . "</pre>\n";
$c = new xmlrpc_client("/server.php", "xmlrpc.heddley.com", 80);
$c->setDebug(1);
$r = $c->send($f);
if (!$r) {
die("send failed");
}
$v = $r->value();
if (!$r->faultCode()) {
print "State number " . $HTTP_POST_VARS["stateno"] . " is " . $v->scalarval() . "<BR>";
// print "<HR>I got this value back<BR><PRE>" .
// htmlentities($r->serialize()). "</PRE><HR>\n";
} else {
print "Fault: ";
print "Code: " . $r->faultCode() . " Reason '" . $r->faultString() . "'<BR>";
}
}
print "<FORM ACTION=\"client.php\" METHOD=\"POST\">\n<INPUT NAME=\"stateno\" VALUE=\"{$stateno}\"><input type=\"submit\" value=\"go\" name=\"submit\"></FORM><P>\nenter a state number to query its name";
?>
</body>
</html>