本文整理汇总了PHP中IXR_Value::getXml方法的典型用法代码示例。如果您正苦于以下问题:PHP IXR_Value::getXml方法的具体用法?PHP IXR_Value::getXml怎么用?PHP IXR_Value::getXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXR_Value
的用法示例。
在下文中一共展示了IXR_Value::getXml方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OutputResult
public function OutputResult($password)
{
if ($this->mode != 'remote') {
return;
}
litepublisher::$options->savemodified();
$result = array('url' => litepublisher::$site->url, 'email' => litepublisher::$options->email, 'password' => $password, 'name' => litepublisher::$site->name, 'description' => litepublisher::$site->description);
switch ($this->resulttype) {
case 'json':
$s = json_encode($result);
header('Content-Type: text/javascript; charset=utf-8');
break;
case 'serialized':
$s = serialize($result);
header('Content-Type: text/plain; charset=utf-8');
break;
case 'xmlrpc':
$r = new IXR_Value($result);
$s = '<?xml version="1.0" encoding="utf-8" ?>
<methodResponse><params><param><value>' . $r->getXml() . '</value></param></params></methodResponse>';
header('Content-Type: text/xml; charset=utf-8');
break;
default:
die('Unknown remote method');
}
header('Connection: close');
header('Last-Modified: ' . date('r'));
Header('Cache-Control: no-cache, must-revalidate');
Header('Pragma: no-cache');
header('Content-Length: ' . strlen($s));
echo $s;
exit;
}
示例2: serve
function serve($data = false)
{
if (!$data) {
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
if (function_exists('status_header')) {
status_header(405);
// WP #20986
header('Allow: POST');
}
header('Content-Type: text/plain');
// merged from WP #9093
die('XML-RPC server accepts POST requests only.');
}
global $HTTP_RAW_POST_DATA;
if (empty($HTTP_RAW_POST_DATA)) {
// workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
$data = file_get_contents('php://input');
} else {
$data =& $HTTP_RAW_POST_DATA;
}
}
$this->message = new IXR_Message($data);
if (!$this->message->parse()) {
$this->error(-32700, 'parse error. not well formed');
}
if ($this->message->messageType != 'methodCall') {
$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
}
$result = $this->call($this->message->methodName, $this->message->params);
// Is the result an error?
if (is_a($result, 'IXR_Error')) {
$this->error($result);
}
// Encode the result
$r = new IXR_Value($result);
$resultxml = $r->getXml();
// Create the XML
$xml = <<<EOD
<methodResponse>
<params>
<param>
<value>
{$resultxml}
</value>
</param>
</params>
</methodResponse>
EOD;
// Send it
$this->output($xml);
}
示例3: OutputResult
public function OutputResult($password)
{
if ($this->mode == 'remote') {
$result = array('url' => litepublisher::$options->url, 'login' => litepublisher::$options->login, 'password' => $password, 'email' => litepublisher::$options->email, 'name' => litepublisher::$options->name, 'description' => litepublisher::$options->description);
switch ($this->resulttype) {
case 'serialized':
$s = serialize($result);
$length = strlen($s);
header('Connection: close');
header('Content-Length: ' . $length);
header('Content-Type: text/plain');
header('Date: ' . date('r'));
echo $s;
exit;
case 'xmlrpc':
require_once litepublisher::$paths->libinclude . 'class-IXR.php';
$r = new IXR_Value($result);
$resultxml = $r->getXml();
// Create the XML
$html = THtmlResource::instance();
$html->section = 'installation';
eval('$xml = "' . $html->xmlrpc . '\\n";');
// Send it
$xml = '<?xml version="1.0"?>' . "\n" . $xml;
$length = strlen($xml);
header('Connection: close');
header('Content-Length: ' . $length);
header('Content-Type: text/xml');
header('Date: ' . date('r'));
echo $xml;
exit;
case 'ini':
$ini = '';
foreach ($result as $key => $value) {
$ini .= "{$key} = \"{$value}\"\n";
}
$length = strlen($ini);
header('Connection: close');
header('Content-Length: ' . $length);
header('Content-Type: text/plain');
header('Date: ' . date('r'));
echo $ini;
exit;
}
}
}
示例4: foreach
/**
* PHP5 constructor.
*/
function __construct($method, $args)
{
$this->method = $method;
$this->args = $args;
$this->xml = <<<EOD
<?xml version="1.0"?>
<methodCall>
<methodName>{$this->method}</methodName>
<params>
EOD;
foreach ($this->args as $arg) {
$this->xml .= '<param><value>';
$v = new IXR_Value($arg);
$this->xml .= $v->getXml();
$this->xml .= "</value></param>\n";
}
$this->xml .= '</params></methodCall>';
}
示例5: api_error
function api_error($msg, $code = 'system_error')
{
Logger::log("XML-RPC api_error occurred: code {$code}, message {$msg}");
$r = new IXR_Value(array('success' => FALSE, 'msg' => $msg, 'code' => $code));
$xml = $r->getXml();
echo <<<EOD
<methodResponse>
<!-- this is an xml-rpc endpoint; try accessing it with an xml-rpc client. more info: http://www.xmlrpc.com/ -->
<params>
<param>
<value>
{$xml}
</value>
</param>
</params>
</methodResponse>
EOD;
exit;
}
示例6: serve
function serve($data = false)
{
if (!$data) {
global $HTTP_RAW_POST_DATA;
if (!$HTTP_RAW_POST_DATA) {
die('XML-RPC server accepts POST requests only.');
}
$rx = '/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m';
#first, handle the known UAs in order to serve proper content
if (strpos('w.bloggar', $_SERVER['HTTP_USER_AGENT']) !== false) {
$encoding = 'iso-8859-1';
# find for supplied encoding before to try other things
} elseif (preg_match($rx, $HTTP_RAW_POST_DATA, $xml_enc)) {
$encoding = strtolower($xml_enc[1]);
# try utf-8 detect
} elseif (preg_match('/^([\\x00-\\x7f]|[\\xc2-\\xdf][\\x80-\\xbf]|\\xe0[\\xa0-\\xbf][\\x80-\\xbf]|[\\xe1-\\xec][\\x80-\\xbf]{2}|\\xed[\\x80-\\x9f][\\x80-\\xbf]|[\\xee-\\xef][\\x80-\\xbf]{2}|f0[\\x90-\\xbf][\\x80-\\xbf]{2}|[\\xf1-\\xf3][\\x80-\\xbf]{3}|\\xf4[\\x80-\\x8f][\\x80-\\xbf]{2})*$/', $HTTP_RAW_POST_DATA) === 1) {
$encoding = 'utf-8';
# otherwise, use iso-8859-1
} else {
$encoding = 'iso-8859-1';
}
switch ($encoding) {
case 'utf-8':
$data = $HTTP_RAW_POST_DATA;
break;
case 'iso-8859-1':
# this will fails on parser if utf8_encode is unavailiable
$data = function_exists('utf8_encode') && is_callable('utf8_encode') ? utf8_encode($HTTP_RAW_POST_DATA) : $HTTP_RAW_POST_DATA;
break;
default:
# this will fails on parser if mb_convert_encoding is unavailiable
$data = function_exists('mb_convert_encoding') && is_callable('mb_convert_encoding') ? mb_convert_encoding($HTTP_RAW_POST_DATA, 'utf-8', $encoding) : $HTTP_RAW_POST_DATA;
break;
}
}
$this->message = new IXR_Message($data);
if (!$this->message->parse()) {
$this->error(-32700, 'parse error. not well formed');
}
if ($this->message->messageType != 'methodCall') {
$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
}
$result = $this->call($this->message->methodName, $this->message->params);
# Is the result an error?
if (is_a($result, 'IXR_Error')) {
$this->error($result);
}
# Encode the result
$r = new IXR_Value($result);
$resultxml = $r->getXml();
# Create the XML
$xml = <<<EOD
<methodResponse>
<params>
<param>
<value>
{$resultxml}
</value>
</param>
</params>
</methodResponse>
EOD;
# Added for testing purposes only
if (!isset($encoding)) {
$encoding = 'utf-8';
}
# Send it
return $this->output($xml, $encoding);
}
示例7: serve
/**
* 服务入口
*
* @access private
* @param mixed $data 输入参数
* @return void
*/
private function serve($data = false)
{
if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");
}
if (isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
$GLOBALS['HTTP_RAW_POST_DATA'] = trim($GLOBALS['HTTP_RAW_POST_DATA']);
}
if (!$data) {
global $HTTP_RAW_POST_DATA;
if (!$HTTP_RAW_POST_DATA) {
die('XML-RPC server accepts POST requests only.');
}
$data = $HTTP_RAW_POST_DATA;
}
$this->message = new IXR_Message($data);
if (!$this->message->parse()) {
$this->error(-32700, 'parse error. not well formed');
}
if ($this->message->messageType != 'methodCall') {
$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
}
if (0 === strpos($this->message->methodName, 'hook.')) {
die('THIS METHOD MUST BE CALLED INSIDE.');
}
$result = $this->call($this->message->methodName, $this->message->params);
// Is the result an error?
if (is_a($result, 'IXR_Error')) {
$this->error($result);
}
// Encode the result
$r = new IXR_Value($result);
$resultxml = $r->getXml();
// Create the XML
$xml = <<<EOD
<methodResponse>
<params>
<param>
<value>
{$resultxml}
</value>
</param>
</params>
</methodResponse>
EOD;
// hook
if ($this->hasMethod('hook.beforeOutput')) {
$this->call('hook.beforeOutput', array());
}
// Send it
$this->output($xml);
}
示例8: serve
function serve($data = false)
{
if (!$data) {
global $HTTP_RAW_POST_DATA;
if (!$HTTP_RAW_POST_DATA) {
// RSD lets them find us via GET requests
$this->rsd();
exit;
}
$rx = '/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m';
// first, handle the known UAs in order to serve proper content
if (strpos('w.bloggar', $_SERVER['HTTP_USER_AGENT']) !== false) {
$encoding = 'iso-8859-1';
} elseif (preg_match($rx, $HTTP_RAW_POST_DATA, $xml_enc)) {
$encoding = strtolower($xml_enc[1]);
} elseif (preg_match('/^([\\x00-\\x7f]|[\\xc2-\\xdf][\\x80-\\xbf]|\\xe0[\\xa0-\\xbf][\\x80-\\xbf]|[\\xe1-\\xec][\\x80-\\xbf]{2}|\\xed[\\x80-\\x9f][\\x80-\\xbf]|[\\xee-\\xef][\\x80-\\xbf]{2}|f0[\\x90-\\xbf][\\x80-\\xbf]{2}|[\\xf1-\\xf3][\\x80-\\xbf]{3}|\\xf4[\\x80-\\x8f][\\x80-\\xbf]{2})*$/', $HTTP_RAW_POST_DATA) === 1) {
$encoding = 'utf-8';
} else {
$encoding = 'iso-8859-1';
}
switch ($encoding) {
case 'utf-8':
$data = $HTTP_RAW_POST_DATA;
break;
case 'iso-8859-1':
#TODO: if utf8 conversion fails, throw: 32701 ---> parse error. unsupported encoding?
#see: http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
// this will fail on parser if utf8_encode is unavailiable
$data = function_exists('utf8_encode') && is_callable('utf8_encode') ? utf8_encode($HTTP_RAW_POST_DATA) : $HTTP_RAW_POST_DATA;
break;
default:
#TODO: if utf8 conversion fails, throw: 32701 ---> parse error. unsupported encoding?
// this will fail on parser if mb_convert_encoding is unavailiable
$data = function_exists('mb_convert_encoding') && is_callable('mb_convert_encoding') ? mb_convert_encoding($HTTP_RAW_POST_DATA, 'utf-8', $encoding) : $HTTP_RAW_POST_DATA;
break;
}
}
$this->message = new IXR_Message($data);
if (!$this->message->parse()) {
$this->error(-32700, 'parse error. not well formed');
}
if ($this->message->messageType != 'methodCall') {
$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
}
$result = $this->call($this->message->methodName, $this->message->params);
// Is the result an error?
if (is_a($result, 'IXR_Error')) {
$this->error($result);
}
// Encode the result
$r = new IXR_Value($result);
$resultxml = $r->getXml();
// Create the XML
$xml = <<<EOD
<methodResponse>
\t<params>
\t\t<param>
\t\t\t<value>
\t\t\t\t{$resultxml}
\t\t\t</value>
\t\t</param>
\t</params>
</methodResponse>
EOD;
return $this->output($xml, $encoding);
}
示例9: foreach
function IXR_Request($method, $args)
{
$this->method = $method;
$this->args = $args;
$this->xml = '<?xml version="1.0" encoding="utf-8" ?><methodCall><methodName>' . $this->method . '</methodName><params>';
foreach ($this->args as $arg) {
$this->xml .= '<param><value>';
$v = new IXR_Value($arg);
$this->xml .= $v->getXml();
$this->xml .= '</value></param>' . LF;
}
$this->xml .= '</params></methodCall>';
}