快速业务通道

PHP xml-rpc远程调用

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-05-25
_exists("$key type", $data)){
$type = $data["$key type"];
}
$temp[] = array(''name'' => $key, ''value'' => XMLRPC_prepare($value, $type));
}
}
}
}
}else{ #it''s a scalar
if(!$type){
if(is_int($data)){
$returnvalue[''int''] = $data;
return $returnvalue;
}elseif(is_float($data)){
$returnvalue[''double''] = $data;
return $returnvalue;
}elseif(is_bool($data)){
$returnvalue[''boolean''] = ($data ? 1 : 0);
return $returnvalue;
}elseif(preg_match(''/^\d{8}T\d{2}:\d{2}:\d{2}$/'', $data, $matches)){ #it''s a date
$returnvalue[''dateTime.iso8601''] = $data;
return $returnvalue;
}elseif(is_string($data)){
$returnvalue[''string''] = htmlspecialchars($data);
return $returnvalue;
}
}else{
$returnvalue[$type] = htmlspecialchars($data);
}
}
return $returnvalue;
}
function & XMLRPC_adjustValue($current_node){
if(is_array($current_node)){
if(isset($current_node[''array''])){
if(!is_array($current_node[''array''][''data''])){
#If there are no elements, return an emptyempty array
return array();
}else{
#echo "Getting rid of array -> data -> value<br>\n";
$temp = $current_node[''array''][''data''][''value''];
if(is_array($temp) and array_key_exists(0, $temp)){
$count = count($temp);
for($n=0;$n<$count;$n++){
$temp2[$n] = &XMLRPC_adjustValue($temp[$n]);
}
$temp = $temp2;
}else{
$temp2 = &XMLRPC_adjustValue($temp);
$temp = array($temp2);
#I do the temp assignment because it avoids copying,
# since I can put a reference in the array
#PHP''s reference model is a bit silly, and I can''t just say:
# $temp = array(&XMLRPC_adjustValue($temp));
}
}
}elseif(isset($current_node[''struct''])){
if(!is_array($current_node[''struct''])){
#If there are no members, return an emptyempty array
return array();
}else{
#echo "Getting rid of struct -> member<br>\n";
$temp = $current_node[''struct''][''member''];
if(is_array($temp) and array_key_exists(0, $temp)){
$count = count($temp);
for($n=0;$n<$count;$n++){
#echo "Passing name {$temp[$n][name]}. Value is: " . show($temp[$n][value], var_dump, true) . "<br>\n";
$temp2[$temp[$n][''name'']] = &XMLRPC_adjustValue($temp[$n][''value'']);
#echo "adjustValue(): After assigning, the value is " . show($temp2[$temp[$n][''name'']], var_dump, true) . "<br>\n";
}
}else{
#echo "Passing name $temp[name]<br>\n";
$temp2[$temp[''name'']] = &XMLRPC_adjustValue($temp[''value'']);
}
$temp = $temp2;
}
}else{
$types = array(''string'', ''int'', ''i4'', ''double'', ''dateTime.iso8601'', ''base64'', ''boolean'');
$fell_through = true;
foreach($types as $type){
if(array_key_exists($type, $current_node)){
#echo "Getting rid of ''$type''<br>\n";
$temp = $current_node[$type];
#echo "adjustValue(): The current node is set with a type of $type<br>\n";
$fell_through = false;
break;
}
}
if($fell_through){
$type = ''string'';
#echo "Fell through! Type is $type<br>\n";
}
switch ($type){
case ''int'': case ''i4'': $temp = (int)$temp; break;
case ''string'': $temp = (string)$temp; break;
case ''double'': $temp = (double)$temp; break;
case ''boolean'': $temp = (bool)$temp; brea

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号