本文整理汇总了PHP中xmlrpc_server_create函数的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpc_server_create函数的具体用法?PHP xmlrpc_server_create怎么用?PHP xmlrpc_server_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlrpc_server_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->server = xmlrpc_server_create();
//http://www.hixie.ch/specs/pingback/pingback
//https://github.com/tedeh/pingback-php
xmlrpc_server_register_method($this->server, 'pingback.ping', [$this, 'pingback_ping']);
}
示例2: __construct
/**
* XMLRPC server constructor
*
* @access private
*/
public function __construct($request, $params = array())
{
parent::__construct($request, $params);
$this->_server = xmlrpc_server_create();
foreach ($GLOBALS['registry']->listMethods() as $method) {
xmlrpc_server_register_method($this->_server, str_replace('/', '.', $method), array('Horde_Rpc_Xmlrpc', '_dispatcher'));
}
}
示例3: handlePost
function handlePost()
{
$server = xmlrpc_server_create();
xmlrpc_server_register_method($server, 'pingback.ping', array($this, 'ping'));
echo xmlrpc_server_call_method($server, file_get_contents('php://input'), null, array('encoding' => 'utf-8'));
xmlrpc_server_destroy($server);
return true;
}
示例4: __construct
public function __construct($options = array())
{
$this->_server = xmlrpc_server_create();
$this->setOptions($options);
if (!xmlrpc_server_register_method($this->_server, 'pingback.ping', array($this, '_ping'))) {
throw new PingbackException('Failed to register method to server');
}
}
示例5: init
/**
* Initialize the XMLRPC server
*
* @return void
*/
protected function init()
{
$this->XmlRpcServer = xmlrpc_server_create();
xmlrpc_server_register_method($this->XmlRpcServer, 'ns1.doSomething', array($this, '_xmlrpc_ns1_doSomething'));
xmlrpc_server_register_method($this->XmlRpcServer, 'ns2.getServerTime', array($this, '_xmlrpc_ns2_getServerTime'));
xmlrpc_server_register_method($this->XmlRpcServer, 'sayHello', array($this, '_xmlrpc_sayHello'));
// TODO how does this work?
//xmlrpc_server_register_introspection_callback($this->XmlRpcServer, array($this, '_xmlrpc_introspection'));
}
示例6: __construct
function __construct($payload, $payload_signed, $payload_encrypted)
{
$this->payload = $payload;
// xmlrpc_decode_request is defined such that the '$method' string is
// passed in by reference.
$this->params = xmlrpc_decode_request($this->payload, $this->method, 'UTF-8');
// The method name is not allowed to have a dot, except for a single dot
// which preceeds the php extension. It can have slashes but it cannot
// begin with a slash. We specifically don't want .. to be possible.
if (0 == preg_match("@^[A-Za-z0-9]+/[A-Za-z0-9/_-]+(\\.php/)?[A-Za-z0-9_-]+\$@", $this->method)) {
throw new XmlrpcServerException('The function does not exist', 6010);
}
if ($payload_signed && $payload_encrypted || $this->method == 'system/keyswap') {
// The remote server's credentials checked out.
// You might want to enable some methods for unsigned/unencrypted
// transport
} else {
// For now, we throw an exception
throw new XmlrpcServerException('The signature on your message was not valid', 6005);
}
// The system methods are treated differently.
if (array_key_exists($this->method, $this->system_methods)) {
$xmlrpcserver = xmlrpc_server_create();
xmlrpc_server_register_method($xmlrpcserver, $this->method, array(&$this, $this->system_methods[$this->method]));
} else {
// Security: I'm thinking that we should not return separate errors for
// the file not existing, the file not being readable, etc. as
// it might provide an opportunity for outsiders to scan the
// server for random files. So just a single message/code for
// all failures here kthxbye.
if (strpos($this->method, '/') !== false) {
$this->callstack = explode('/', $this->method);
} else {
throw new XmlrpcServerException('The function does not exist', 6011);
}
// Read custom xmlrpc functions from local
if (function_exists('local_xmlrpc_services')) {
foreach (local_xmlrpc_services() as $name => $localservices) {
$this->services[$name] = array_merge($this->services[$name], $localservices);
}
}
foreach ($this->services as $container) {
if (array_key_exists($this->method, $container)) {
$xmlrpcserver = xmlrpc_server_create();
$bool = xmlrpc_server_register_method($xmlrpcserver, $this->method, 'api_dummy_method');
$this->response = xmlrpc_server_call_method($xmlrpcserver, $payload, $container[$this->method], array("encoding" => "utf-8"));
$bool = xmlrpc_server_destroy($xmlrpcserver);
return $this->response;
}
}
throw new XmlrpcServerException('No such method: ' . $this->method);
}
$temp = '';
$this->response = xmlrpc_server_call_method($xmlrpcserver, $payload, $temp, array("encoding" => "utf-8"));
return $this->response;
}
示例7: process
/**
* Processes an incoming request, executes it and builds a response.
*
* @since 5.1
* @param ModuleServerRequest $request Incoming request.
* @param ModuleServerResponse $response Outcoming response.
* @return void
*/
public function process(ModuleServerRequest $request, ModuleServerResponse $response)
{
$command = explode(' ', $request->getCommand());
$module_location = $command[1];
if (!strlen($module_location)) {
$response->sendWarning(ModuleServerResponse::SC_NOT_FOUND, 'Module location not defined.', ModuleServerRsponse::ERROR_CLASSNAME_MISSING);
return;
}
try {
$locator = new ModuleLocator('module://' . $request->getHeader('User') . ':' . $request->getHeader('Password') . '@/' . $module_location);
$sessionId = $request->getHeader('Session');
if ($sessionId) {
$this->module = ModuleFactory::getSessionModule($locator, $sessionId);
} else {
$this->module = ModuleFactory::getModule($locator);
}
} catch (ModuleException $e) {
$response->sendWarning(ModuleServerResponse::SC_INTERNAL_SERVER_ERROR, $e->__toString());
return;
} catch (\Exception $e) {
$response->sendWarning(ModuleServerResponse::SC_INTERNAL_SERVER_ERROR, $e->__toString());
return;
}
if (!($xmlrpc_server = xmlrpc_server_create())) {
$response->sendWarning(ModuleServerResponse::SC_INTERNAL_SERVER_ERROR, 'Internal error: Could not create an XML-RPC server.', ModuleServerResponse::ERROR_XMLRPC_ERROR);
return;
}
$theClass = new \ReflectionObject($this->module);
$methods = $theClass->getMethods();
foreach ($methods as $method) {
// Ignore private methods
$theMethod = new \ReflectionMethod($theClass->getName(), $method->getName());
if (!$theMethod->isPublic()) {
continue;
}
// Expose only methods beginning with "module" prefix
if (!(substr($method->getName(), 0, 6) == 'module')) {
continue;
}
xmlrpc_server_register_method($xmlrpc_server, strtolower($method->getName()), array($this, 'xmlrpcGateway'));
}
xmlrpc_server_register_introspection_callback($xmlrpc_server, array($this, 'introspectionGateway'));
try {
$buffer = xmlrpc_server_call_method($xmlrpc_server, $request->getPayload(), '', array('output_type' => 'xml'));
$response->addHeader('Module/1.0 ' . ModuleServerResponse::SC_OK);
$response->setBuffer($buffer);
} catch (\Exception $e) {
$response->addHeader('Module/1.0 ' . ModuleServerResponse::SC_INTERNAL_ERROR);
$response->setBuffer($buffer);
}
xmlrpc_server_destroy($xmlrpc_server);
$context = new ModuleContext($module_location);
$session = new \Innomatic\Module\Session\ModuleSession($context, $sessionId);
$session->save($this->module);
$response->addHeader('Session: ' . $session->getId());
}
示例8: xmlrpc_server
function xmlrpc_server($dispMap = '', $serviceNow = 0)
{
$this->server = xmlrpc_server_create();
if ($dispMap) {
$this->dmap = $dispMap;
if ($serviceNow) {
$this->service();
}
}
}
示例9: __construct
/**
* Create a new XML-RPC Server.
*
* The constructor receives a mandatory parameter: the Call Handler. The call handler executes the actual
* method call. XML_RPC2 server acts as a protocol decoder/encoder between the call handler and the client
*
* @param object $callHandler
* @param array $options associative array of options
*/
function __construct($callHandler, $options = array())
{
parent::__construct($callHandler, $options);
$this->_xmlrpcextServer = xmlrpc_server_create();
foreach ($callHandler->getMethods() as $method) {
if (xmlrpc_server_register_method($this->_xmlrpcextServer, $method->getName(), array($this, 'epiFunctionHandlerAdapter')) !== true) {
throw new XML_RPC2_Exception('Unable to setup XMLRPCext server. xmlrpc_server_register_method returned non-true.');
}
}
}
示例10: __construct
/**
* Constructeur.
*
* @access protected
*/
function __construct()
{
$this->_server = xmlrpc_server_create();
$this->auth = false;
$this->_logger = Tools::loggerFactory();
$this->registerMethod('test');
$this->registerMethod('auth.login');
$this->registerMethod('i18n.setLocale');
$this->registerMethod('i18n.getSupportedLocales');
$this->registerMethod('session.register');
}
示例11: __construct
/**
* XMLRPC server constructor.
*/
function __construct($request, $params = array())
{
parent::__construct($request, $params);
$this->_server = xmlrpc_server_create();
// Register only phpgw services.
foreach ($GLOBALS['registry']->listMethods('phpgw') as $method) {
$methods = explode('/', $method);
array_shift($methods);
$method = implode('.', $methods);
xmlrpc_server_register_method($this->_server, $method, array('Horde_Rpc_Phpgw', '_dispatcher'));
}
}
示例12: serializationAction
/**
* This won't ever be called unless there is an error
*/
function serializationAction(&$body)
{
$request_xml = $body->getValue();
$toSerialize = $body->getResults();
$lambdaFunc = 'return $userData;';
$func = create_function('$a,$b,$userData', $lambdaFunc);
$xmlrpc_server = xmlrpc_server_create();
$request_xml = $body->getValue();
xmlrpc_server_register_method($xmlrpc_server, $body->packageClassMethodName, $func);
$response = xmlrpc_server_call_method($xmlrpc_server, $request_xml, $toSerialize);
$body->setResults($response);
}
示例13: __construct
public function __construct()
{
$this->director = Director::getInstance();
if (!function_exists("xmlrpc_server_create")) {
require_once "xmlrpc/xmlrpc.inc";
require_once "xmlrpc/xmlrpcs.inc";
require_once "xmlrpc/xmlrpc_wrappers.inc";
require_once "xmlrpc/xmlrpc_extension_api.inc";
}
$this->server = xmlrpc_server_create();
$this->log = Logger::getInstance();
}
示例14: processRequest
/**
* Request processor
* @param object $handler
* @param array|bool $methodsList If omitted, handler should contain getMethods() method
* @return string
*/
public function processRequest($handler, $methodsList = false)
{
$server = xmlrpc_server_create();
if (!$methodsList) {
$methodsList = $handler->getMethods();
}
foreach ($methodsList as $method) {
xmlrpc_server_register_method($server, $method, [$handler, $method]);
}
$request = (isset($HTTP_RAW_POST_DATA) and $HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : file_get_contents('php://input');
$response = xmlrpc_server_call_method($server, $request, null);
xmlrpc_server_destroy($server);
return $response;
}
示例15: setUpXmlRpcTypes
private function setUpXmlRpcTypes($xmlrpc_das)
{
$typeList = <<<END
<introspection>
<typeList>
<typeDescription name='SimpleType' basetype='struct' desc='Simple type'>
<value type='int' name='intValue'></value>
<value type='double' name='doubleValue'></value>
<value type='string' name='strValue'></value>
</typeDescription>
<typeDescription name='ComplexType' basetype='struct' desc='Complex type'>
<value type='SimpleType []' name='objArrValue'></value>
<value type='int []' name='intArrValue'></value>
<value type='int' name='intValue'></value>
<value type='double' name='doubleValue'></value>
<value type='string' name='strValue'></value>
<value type='SimpleType' name='objValue'></value>
</typeDescription>
</typeList>
</introspection>
END;
$call = <<<END
<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>system.describeMethods</methodName>
<params/>
</methodCall>
END;
$xmlrpc_server = xmlrpc_server_create();
$descArray = xmlrpc_parse_method_descriptions($typeList);
xmlrpc_server_add_introspection_data($xmlrpc_server, $descArray);
$response = xmlrpc_server_call_method($xmlrpc_server, $call, null);
xmlrpc_server_destroy($xmlrpc_server);
$methodDesc = xmlrpc_decode_request($response, $method);
$this->xmlrpc_das->addTypesXmlRpc($methodDesc["typeList"]);
}