本文整理汇总了PHP中xmlrpc_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpc_encode函数的具体用法?PHP xmlrpc_encode怎么用?PHP xmlrpc_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlrpc_encode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: outputFilter
public function outputFilter($data, stdClass $context)
{
if (isset($context->userdata->format) && $context->userdata->format === "xmlrpc") {
$result = null;
if ($data !== "") {
$stream = new BytesIO($data);
$reader = new Reader($stream);
while (($tag = $stream->getc()) !== Tags::TagEnd) {
$reader->reset();
switch ($tag) {
case Tags::TagResult:
$result = $reader->unserialize();
break;
case Tags::TagError:
$lasterror = error_get_last();
$result = array("faultCode" => $lasterror["type"], "faultString" => $reader->unserialize());
break;
case Tags::TagFunctions:
$result = $reader->unserialize();
break;
default:
return xmlrpc_encode($result);
}
}
}
$data = xmlrpc_encode($result);
}
return $data;
}
开发者ID:wanggeopens,项目名称:own-libs,代码行数:29,代码来源:ServiceFilter.php
示例2: make
public static function make($data)
{
if (!self::$type || !is_array($data)) {
return false;
}
$dd = array();
foreach ($data as $d) {
if (is_object($d)) {
$dd[] = $d->toArray();
}
if (is_array($d)) {
$dd[] = $d;
} else {
$dd[] = array($d);
}
}
if (self::$type == 'json') {
header('Content-Type: application/json');
die(json_encode($dd));
}
if (self::$type == 'xml') {
header('Content-Type: application/xml; charset=utf-8');
die(xmlrpc_encode($dd));
}
return false;
}
开发者ID:Aranjedeath,项目名称:l4-starter,代码行数:26,代码来源:Api.php
示例3: 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;
}
开发者ID:BackupTheBerlios,项目名称:sotf-svn,代码行数:34,代码来源:rpc_Utils.class.php
示例4: _processViewerTableUpdate
function _processViewerTableUpdate($viewer)
{
$sql = "REPLACE INTO " . TB_USERLOG_VIEWERS . "(viewer) VALUES ('{$viewer}')";
$result = mysql_query($sql);
if (!$result) {
$response_xml = xmlrpc_encode(array('success' => $result, 'errorMessage' => mysql_error()));
print $response_xml;
die;
}
}
开发者ID:AlphaStaxLLC,项目名称:opensim-userlogmodule,代码行数:10,代码来源:agentlog.php
示例5: Display
public static function Display($data)
{
if (self::$type && is_array($data)) {
if (self::$type == 'json') {
return json_encode($data);
}
if (self::$type == 'xml') {
return xmlrpc_encode($data);
}
}
}
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:11,代码来源:Api.php
示例6: payload
/**
Returns the xmlrpc payload for the response.
*/
function payload()
{
if ($this->IsFault) {
$payload = xmlrpc_encode(array("faultCode" => $this->FaultCode, "faultString" => $this->FaultString));
return str_replace(array('<fault>', '</fault>'), array('<methodResponse><fault>', '</fault></methodResponse>'), $payload);
} else {
$payload = xmlrpc_encode($this->Value);
/// @todo verify if user gave us back an array with faultString / faultCode members,
/// as we will be sending back junk in that case...
return str_replace(array('<params>', '</params>'), array('<methodResponse><params>', '</params></methodResponse>'), $payload);
}
}
开发者ID:gggeek,项目名称:ggwebservices,代码行数:15,代码来源:ggxmlrpcresponse.php
示例7: xmlrpc_encode
function xmlrpc_encode($php_val)
{
global $xmlrpcInt;
global $xmlrpcDouble;
global $xmlrpcString;
global $xmlrpcArray;
global $xmlrpcStruct;
global $xmlrpcBoolean;
$type = gettype($php_val);
$xmlrpc_val = new xmlrpcval();
switch ($type) {
case "array":
case "object":
$arr = array();
while (list($k, $v) = each($php_val)) {
$arr[$k] = xmlrpc_encode($v);
}
$xmlrpc_val->addStruct($arr);
break;
case "integer":
$xmlrpc_val->addScalar($php_val, $xmlrpcInt);
break;
case "double":
$xmlrpc_val->addScalar($php_val, $xmlrpcDouble);
break;
case "string":
$xmlrpc_val->addScalar($php_val, $xmlrpcString);
break;
// <G_Giunta_2001-02-29>
// Add support for encoding/decoding of booleans, since they are supported in PHP
// <G_Giunta_2001-02-29>
// Add support for encoding/decoding of booleans, since they are supported in PHP
case "boolean":
$xmlrpc_val->addScalar($php_val, $xmlrpcBoolean);
break;
// </G_Giunta_2001-02-29>
// </G_Giunta_2001-02-29>
case "unknown type":
default:
// giancarlo pinerolo <[email protected]>
// it has to return
// an empty object in case (which is already
// at this point), not a boolean.
break;
}
return $xmlrpc_val;
}
开发者ID:n0nick,项目名称:n0where,代码行数:47,代码来源:coding.php
示例8: retrieve_email
function retrieve_email($method_name, $params, $app_data)
{
$req = $params[0];
$object = $req['objectid'];
$rows = $req['number'];
$sql = "SELECT `timestamp`,`subject`, `from`,`objectname`,`region`,`objectlocation`,`message` FROM email WHERE `to` = '" . mysql_escape_string($object) . "' LIMIT 0," . $rows;
$result = mysql_query($sql);
$data = array();
while ($row = mysql_fetch_assoc($result)) {
$data[] = array("timestamp" => $row["timestamp"], "subject" => $row["subject"], "sender" => $row["from"], "objectname" => $row["objectname"], "region" => $row["region"], "objectpos" => $row["objectlocation"], "message" => $row["message"]);
}
// Now delete the email from the database
$delete = "DELETE FROM email WHERE `to` = '" . mysql_escape_string($object) . "'";
$result = mysql_query($delete);
$response_xml = xmlrpc_encode(array('success' => True, 'errorMessage' => "", 'data' => $data));
print $response_xml;
}
开发者ID:QuillLittlefeather,项目名称:OpenSim.Email,代码行数:17,代码来源:xmlrpc.php
示例9: executeRPC2
/**
* This is the main handle for the xmlrpc calls
*/
public function executeRPC2($request)
{
// get all the defined RPC
$rpc_functions = $this->getRPCFunctions();
// http POST method is required for modifying the database
$this->forward404Unless($request->isMethod('post'), "HTTP POST is required");
// log to debug
ezDbg::err("enter xmlrpc");
// get xmlrpc request string posted as a raw
$xmlrpc_reqstr = file_get_contents("php://input");
// parse the xmlrpc_reqstr
$method_name = null;
$xmlrpc_params = xmlrpc_decode_request($xmlrpc_reqstr, &$method_name);
ezDbg::err("enter method_name={$method_name} xmlrpc param=" . print_r($xmlrpc_params, true));
if (!isset($rpc_functions[$method_name])) {
$xmlrpc_resp = array("faultCode" => 1, "faultString" => "unknown method name (" . $method_name . ")");
} else {
$rpc_function = $rpc_functions[$method_name];
$nparam = $rpc_function['nparam'];
if (count($xmlrpc_params) < $nparam) {
$xmlrpc_resp = array("faultCode" => 1, "faultString" => $method_name . " require " . $nparam . " parameters.");
} else {
try {
ezDbg::err('trying to call (' . $rpc_function['function'] . ')', $xmlrpc_params);
$xmlrpc_resp = call_user_func_array($rpc_function['function'], $xmlrpc_params);
//$xmlrpc_resp = sfWebRPCPluginDemo::superAddFct(2,3);
} catch (Exception $e) {
$xmlrpc_resp = array("faultCode" => 1, "faultString" => "" . $e->getMessage());
}
}
}
// encode the xmlrpc_resp
$xmlrpc_respstr = xmlrpc_encode($xmlrpc_resp);
// KLUDGE: xmlrpc_encode is unable to add the methodResponse required
$arr = split("\n", $xmlrpc_respstr);
$arr[0] .= "\n<methodResponse>";
$arr[count($arr) - 1] = "</methodResponse>";
$xmlrpc_respstr = implode("\n", $arr);
ezDbg::err("enter xmlrpc resp=" . print_r($xmlrpc_respstr, true));
// disable the web_debug bar
sfConfig::set('sf_web_debug', false);
// return the $value in xml
$this->getResponse()->setHttpHeader('Content-Type', 'text/xml');
return $this->renderText($xmlrpc_respstr);
}
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:48,代码来源:BaseWebRPCActions.class.php
示例10: 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_encode($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']);
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_decode($retval);
}
//debug("Response", $retval);
return $retval;
}
return NULL;
}
开发者ID:BackupTheBerlios,项目名称:sotf-svn,代码行数:42,代码来源:rpc_Utils.class.php
示例11: encodeResponse
function encodeResponse($response)
{
$respClass = strtolower(@get_class($response));
if ($respClass == 'pwgerror') {
$code = $response->code();
$msg = htmlspecialchars($response->message());
$ret = <<<EOD
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>{$code}</int></value>
</member>
<member>
<name>faultString</name>
<value><string>{$msg}</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>
EOD;
return $ret;
}
parent::flattenResponse($response);
$ret = xmlrpc_encode($response);
$ret = <<<EOD
<methodResponse>
<params>
<param>
<value>
{$ret}
</value>
</param>
</params>
</methodResponse>
EOD;
return $ret;
}
开发者ID:donseba,项目名称:Piwigo,代码行数:41,代码来源:xmlrpc_encoder.php
示例12: syncResp
function syncResp($params)
{
debug("incoming SYNC request");
$lastSync = xmlrpc_decode($params->getParam(0));
$nodeData = xmlrpc_decode($params->getParam(1));
$objects = xmlrpc_decode($params->getParam(2));
$neighbour = sotf_Neighbour::getById($nodeData['node_id']);
if (!$neighbour) {
logError("No access: you are not an allowed neighbour node!");
return new xmlrpcresp(0, XMLRPC_ERR_NO_ACCESS, "No access: you are not an allowed neighbour node!");
}
$msg = checkAccess($neighbour);
if ($msg) {
logError($msg);
return new xmlrpcresp(0, XMLRPC_ERR_NO_ACCESS, "No access: {$msg}!");
}
$retval = $neighbour->syncResponse($lastSync, $nodeData, $objects);
// send response
$retval = xmlrpc_encode($retval);
return new xmlrpcresp($retval);
}
开发者ID:BackupTheBerlios,项目名称:sotf-svn,代码行数:21,代码来源:xmlrpcServer.php
示例13: to_xml_rpc
function to_xml_rpc()
{
if (function_exists('xmlrpc_encode')) {
return xmlrpc_encode($this->driver->record);
}
return false;
}
开发者ID:esconsut1,项目名称:php-rails-clone,代码行数:7,代码来源:activerecord.php
示例14: render_output
/**
* Renders the output after preperation.
* @see vB_Template::render()
*
* @param boolean Whether to suppress the HTML comment surrounding option (for JS, etc)
* @return string
*/
protected function render_output($suppress_html_comments = false, $nopermissioncheck = false)
{
return xmlrpc_encode($this->registered);
}
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:11,代码来源:class_core.php
示例15: array
<?php
$params = array("one" => "red", "two" => "blue", "three" => "green");
$response = xmlrpc_encode($params);
echo $response;
$params = array("red", "blue", "green");
$response = xmlrpc_encode($params);
echo $response;
$params = array(0 => "red", 1 => "blue", 3 => "green");
$response = xmlrpc_encode($params);
echo $response;
开发者ID:zaky-92,项目名称:php-1,代码行数:11,代码来源:ext_xmlrpc_tests_003.php
示例16: getProgrammes
function getProgrammes($params)
{
global $config, $db;
$prglist = xmlrpc_decode($params->getParam(0));
$query = "SELECT programmes.* FROM (";
$query .= " SELECT sotf_programmes.*, sotf_stations.name as station, sotf_series.title as seriestitle, sotf_series.description as seriesdescription, sotf_prog_rating.rating_value as rating FROM sotf_programmes";
$query .= " LEFT JOIN sotf_stations ON sotf_programmes.station_id = sotf_stations.id";
$query .= " LEFT JOIN sotf_series ON sotf_programmes.series_id = sotf_series.id";
$query .= " LEFT JOIN sotf_prog_rating ON sotf_programmes.id = sotf_prog_rating.id";
$query .= ") as programmes WHERE published = 't'";
$results = array();
foreach ($prglist as $prg) {
// debug("------------>".$prg."<------------------");
// debug("------------>".$query." AND id = '$prg'<------------------");
$results[] = $db->getRow($query . " AND id = '{$prg}'");
}
foreach ($results as $key => $result) {
// debug("------------>".$result['id']."<------------------");
$icon = sotf_Blob::cacheIcon($result['id']);
$results[$key]['icon'] = $config['cacheUrl'] . "/" . $result['id'] . ".png";
//TODO if no icon {$IMAGEDIR}/noicon.png $imageprefix????
}
$retval = xmlrpc_encode($results);
return new xmlrpcresp($retval);
}
开发者ID:BackupTheBerlios,项目名称:sotf-svn,代码行数:25,代码来源:xmlrpcServer.php
示例17: provideSerializeData
public function provideSerializeData()
{
return array(array(['test' => 1], xmlrpc_encode(['test' => 1])), array(['test' => "abc"], xmlrpc_encode(['test' => "abc"])), array(['test' => [1, 2, 3]], xmlrpc_encode(['test' => [1, 2, 3]])), array(['test' => ["test" => 1]], xmlrpc_encode(['test' => ["test" => 1]])));
}
开发者ID:moriony,项目名称:rpc-server,代码行数:4,代码来源:XmlRpcSerializerTest.php
示例18: date
<?php
$params = date("Ymd\\TH:i:s", time());
xmlrpc_set_type($params, 'datetime');
echo xmlrpc_encode($params);
开发者ID:gleamingthecube,项目名称:php,代码行数:5,代码来源:ext_xmlrpc_tests_bug18916.php
示例19: var_dump
<?php
var_dump(xmlrpc_encode(1.123456789));
var_dump(xmlrpc_encode(11234567891010));
var_dump(xmlrpc_encode(11234567));
var_dump(xmlrpc_encode(""));
var_dump(xmlrpc_encode("test"));
var_dump(xmlrpc_encode("1.22222222222222222222222"));
echo "Done\n";
开发者ID:gleamingthecube,项目名称:php,代码行数:9,代码来源:ext_xmlrpc_tests_bug40576_64bit.php
示例20: rs2xmlrpcval_body
/**
* Builds an xmlrpc struct value out of an AdoDB recordset
* (data values only, no data definition)
*/
function rs2xmlrpcval_body($adodbrs)
{
$numfields = $adodbrs->FieldCount();
// build structure containing recordset data
$adodbrs->MoveFirst();
$rows = array();
while (!$adodbrs->EOF) {
$columns = array();
// This should work on all cases of fetch mode: assoc, num, both or default
if ($adodbrs->fetchMode == 'ADODB_FETCH_BOTH' || count($adodbrs->fields) == 2 * $adodbrs->FieldCount()) {
for ($i = 0; $i < $numfields; $i++) {
if ($adodbrs->fields[$i] === null) {
$columns[$i] = new xmlrpcval('');
} else {
$columns[$i] = xmlrpc_encode($adodbrs->fields[$i]);
}
}
} else {
foreach ($adodbrs->fields as $val) {
if ($val === null) {
$columns[] = new xmlrpcval('');
} else {
$columns[] = xmlrpc_encode($val);
}
}
}
$rows[] = new xmlrpcval($columns, "array");
$adodbrs->MoveNext();
}
$body = new xmlrpcval($rows, "array");
return $body;
}
开发者ID:zsolt-molnar,项目名称:TYPO3-4.5-trunk,代码行数:36,代码来源:toxmlrpc.inc.php
注:本文中的xmlrpc_encode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论