本文整理汇总了PHP中Zend_XmlRpc_Value::getXmlRpcTypeByValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_XmlRpc_Value::getXmlRpcTypeByValue方法的具体用法?PHP Zend_XmlRpc_Value::getXmlRpcTypeByValue怎么用?PHP Zend_XmlRpc_Value::getXmlRpcTypeByValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_XmlRpc_Value
的用法示例。
在下文中一共展示了Zend_XmlRpc_Value::getXmlRpcTypeByValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetXmlRpcTypeByValueThrowsExceptionOnInvalidValue
public function testGetXmlRpcTypeByValueThrowsExceptionOnInvalidValue()
{
$this->setExpectedException('Zend_XmlRpc_Value_Exception');
Zend_XmlRpc_Value::getXmlRpcTypeByValue(fopen(__FILE__, 'r'));
}
示例2: call
/**
* Send an XML-RPC request to the service (for a specific method)
*
* @param string $method Name of the method we want to call
* @param array $params Array of parameters for the method
* @return mixed
* @throws Zend_XmlRpc_Client_FaultException
*/
public function call($method, $params = array())
{
if (!$this->skipSystemLookup() && 'system.' != substr($method, 0, 7)) {
// Ensure empty array/struct params are cast correctly
// If system.* methods are not available, bypass. (ZF-2978)
$success = true;
try {
$signatures = $this->getIntrospector()->getMethodSignature($method);
} catch (Zend_XmlRpc_Exception $e) {
$success = false;
}
if ($success) {
$validTypes = array(Zend_XmlRpc_Value::XMLRPC_TYPE_ARRAY, Zend_XmlRpc_Value::XMLRPC_TYPE_BASE64, Zend_XmlRpc_Value::XMLRPC_TYPE_BOOLEAN, Zend_XmlRpc_Value::XMLRPC_TYPE_DATETIME, Zend_XmlRpc_Value::XMLRPC_TYPE_DOUBLE, Zend_XmlRpc_Value::XMLRPC_TYPE_I4, Zend_XmlRpc_Value::XMLRPC_TYPE_INTEGER, Zend_XmlRpc_Value::XMLRPC_TYPE_NIL, Zend_XmlRpc_Value::XMLRPC_TYPE_STRING, Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT);
if (!is_array($params)) {
$params = array($params);
}
foreach ($params as $key => $param) {
if ($param instanceof Zend_XmlRpc_Value) {
continue;
}
if (count($signatures) > 1) {
$type = Zend_XmlRpc_Value::getXmlRpcTypeByValue($param);
foreach ($signatures as $signature) {
if (!is_array($signature)) {
continue;
}
if (isset($signature['parameters'][$key])) {
if ($signature['parameters'][$key] == $type) {
break;
}
}
}
} elseif (isset($signatures[0]['parameters'][$key])) {
$type = $signatures[0]['parameters'][$key];
} else {
$type = null;
}
if (empty($type) || !in_array($type, $validTypes)) {
$type = Zend_XmlRpc_Value::AUTO_DETECT_TYPE;
}
$params[$key] = Zend_XmlRpc_Value::getXmlRpcValue($param, $type);
}
}
}
$request = $this->_createRequest($method, $params);
$this->doRequest($request);
if ($this->_lastResponse->isFault()) {
$fault = $this->_lastResponse->getFault();
/**
* Exception thrown when an XML-RPC fault is returned
* @see Zend_XmlRpc_Client_FaultException
*/
require_once 'Zend/XmlRpc/Client/FaultException.php';
throw new Zend_XmlRpc_Client_FaultException($fault->getMessage(), $fault->getCode());
}
return $this->_lastResponse->getReturnValue();
}