本文整理匯總了PHP中Zend_XmlRpc_Value::getXmlRpcValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_XmlRpc_Value::getXmlRpcValue方法的具體用法?PHP Zend_XmlRpc_Value::getXmlRpcValue怎麽用?PHP Zend_XmlRpc_Value::getXmlRpcValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_XmlRpc_Value
的用法示例。
在下文中一共展示了Zend_XmlRpc_Value::getXmlRpcValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: serialize
/**
* {@inheritdoc}
*/
public function serialize($method, array $params = [])
{
$toBeVisited = [&$params];
while (isset($toBeVisited[0]) && ($value =& $toBeVisited[0])) {
$type = gettype($value);
if ($type === 'array') {
// Zend converts non-zero-indexed arrays to structs
if (array_keys($value) !== range(0, count($value) - 1) && array_keys($value) == range(1, count($value))) {
$value = array_values($value);
}
foreach ($value as &$child) {
$toBeVisited[] =& $child;
}
} elseif ($type === 'object') {
if ($value instanceof \DateTime) {
$value = \Zend_XmlRpc_Value::getXmlRpcValue($value->format('Ymd\\TH:i:s'), \Zend_XmlRpc_Value::XMLRPC_TYPE_DATETIME);
} elseif ($value instanceof Base64) {
$value = \Zend_XmlRpc_Value::getXmlRpcValue($value->getDecoded(), \Zend_XmlRpc_Value::XMLRPC_TYPE_BASE64);
} else {
$value = get_object_vars($value);
}
} elseif ($type === 'resource') {
throw new InvalidTypeException($value);
}
array_shift($toBeVisited);
}
$request = new \Zend_XmlRpc_Request($method, $params);
try {
return $request->saveXml();
} catch (\Exception $e) {
throw new SerializerException($e->getMessage(), $e->getCode(), $e);
}
}
示例2: _mockXmlRpcClient
protected function _mockXmlRpcClient($method, $retval, $params = array())
{
$this->_xmlRpcMock = $this->getMock('Zend_XmlRpc_Client', array('setSkipSystemLookup', 'call'), array('http://foo'));
$this->_xmlRpcMock->expects($this->once())->method('setSkipSystemLookup')->with(true);
$params = array_merge($params, array('apikey' => $this->_gravatarXmlRpc->getApiKey()));
$this->_xmlRpcMock->expects($this->once())->method('call')->with('grav.' . $method, array(Zend_XmlRpc_Value::getXmlRpcValue($params, Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT)))->will($this->returnValue($retval));
$this->_gravatarXmlRpc->setXmlRpcClient($this->_xmlRpcMock);
}
示例3: model_saved
public function model_saved($observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
if ($this->new_order) {
$customer_id = (string) $order->getCustomerId();
if ($customer_id == '0') {
$customer_id = '';
}
$this->affiliate_call('order_placed', array(Zend_XmlRpc_Value::getXmlRpcValue($_GET, Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT), Zend_XmlRpc_Value::getXmlRpcValue($_COOKIE, Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT), (string) $order->getRealOrderId(), (string) ($order->getData('subtotal') - $order->getData('discount_amount')), $order->getData('customer_email'), $order->getCustomerName(), $customer_id));
}
if ($order->getStatus() == "complete") {
$this->affiliate_call('order_shipped', array((string) $order->getRealOrderId()));
}
return $this;
}
示例4: _getXmlRpcParams
/**
* Retrieve method parameters as XMLRPC values
*
* @return array
*/
protected function _getXmlRpcParams()
{
$params = array();
foreach ($this->_xmlRpcParams as $param) {
$value = $param['value'];
$type = isset($param['type']) ? $param['type'] : null;
$params[] = Zend_XmlRpc_Value::getXmlRpcValue($value);
}
return $params;
}
示例5: loadXml
/**
* Load a response from an XML response
*
* Attempts to load a response from an XMLRPC response, autodetecting if it
* is a fault response.
*
* @param string $response
* @return boolean True if a valid XMLRPC response, false if a fault
* response or invalid input
*/
public function loadXml($response)
{
if (!is_string($response)) {
$this->_fault = new Zend_XmlRpc_Fault(650);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
$xml = Zend_Xml_Security::scan($response);
} catch (Zend_Xml_Exception $e) {
// Not valid XML
$this->_fault = new Zend_XmlRpc_Fault(651);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
if (!empty($xml->fault)) {
// fault response
$this->_fault = new Zend_XmlRpc_Fault();
$this->_fault->setEncoding($this->getEncoding());
$this->_fault->loadXml($response);
return false;
}
if (empty($xml->params)) {
// Invalid response
$this->_fault = new Zend_XmlRpc_Fault(652);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
if (!isset($xml->params) || !isset($xml->params->param) || !isset($xml->params->param->value)) {
require_once 'Zend/XmlRpc/Value/Exception.php';
throw new Zend_XmlRpc_Value_Exception('Missing XML-RPC value in XML');
}
$valueXml = $xml->params->param->value->asXML();
$value = Zend_XmlRpc_Value::getXmlRpcValue($valueXml, Zend_XmlRpc_Value::XML_STRING);
} catch (Zend_XmlRpc_Value_Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(653);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->setReturnValue($value->getValue());
return true;
}
示例6: testXmlRpcObjectsAreNotConverted
/**
* @group ZF-8074
*/
public function testXmlRpcObjectsAreNotConverted()
{
$this->mockIntrospector();
$this->mockedIntrospector->expects($this->exactly(1))->method('getMethodSignature')->with('date.method')->will($this->returnValue(array(array('parameters' => array('dateTime.iso8601', 'string')))));
$expects = 'date.method response';
$this->setServerResponseTo($expects);
$this->assertSame($expects, $this->xmlrpcClient->call('date.method', array(Zend_XmlRpc_Value::getXmlRpcValue(time(), Zend_XmlRpc_Value::XMLRPC_TYPE_DATETIME), 'foo')));
}
示例7: loadXml
/**
* Load a response from an XML response
*
* Attempts to load a response from an XMLRPC response, autodetecting if it
* is a fault response.
*
* @param string $response
* @return boolean True if a valid XMLRPC response, false if a fault
* response or invalid input
*/
public function loadXml($response)
{
if (!is_string($response)) {
$this->_fault = new Zend_XmlRpc_Fault(650);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
$useInternalXmlErrors = libxml_use_internal_errors(true);
$xml = new SimpleXMLElement($response);
libxml_use_internal_errors($useInternalXmlErrors);
} catch (Exception $e) {
libxml_use_internal_errors($useInternalXmlErrors);
// Not valid XML
$this->_fault = new Zend_XmlRpc_Fault(651);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
if (!empty($xml->fault)) {
// fault response
$this->_fault = new Zend_XmlRpc_Fault();
$this->_fault->setEncoding($this->getEncoding());
$this->_fault->loadXml($response);
return false;
}
if (empty($xml->params)) {
// Invalid response
$this->_fault = new Zend_XmlRpc_Fault(652);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
if (!isset($xml->params) || !isset($xml->params->param) || !isset($xml->params->param->value)) {
throw new Zend_XmlRpc_Value_Exception('Missing XML-RPC value in XML');
}
$valueXml = $xml->params->param->value->asXML();
$value = Zend_XmlRpc_Value::getXmlRpcValue($valueXml, Zend_XmlRpc_Value::XML_STRING);
} catch (Zend_XmlRpc_Value_Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(653);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->setReturnValue($value->getValue());
return true;
}
示例8: _handle
/**
* Handle an xmlrpc call (actual work)
*
* @param Zend_XmlRpc_Request $request
* @return Zend_XmlRpc_Response
* @throws Zend_XmlRpcServer_Exception|Exception
* Zend_XmlRpcServer_Exceptions are thrown for internal errors; otherwise,
* any other exception may be thrown by the callback
*/
protected function _handle(Zend_XmlRpc_Request $request)
{
$method = $request->getMethod();
// Check for valid method
if (!$this->_table->hasMethod($method)) {
require_once 'Zend/XmlRpc/Server/Exception.php';
throw new Zend_XmlRpc_Server_Exception('Method "' . $method . '" does not exist', 620);
}
$info = $this->_table->getMethod($method);
$params = $request->getParams();
$argv = $info->getInvokeArguments();
if (0 < count($argv) and $this->sendArgumentsToAllMethods()) {
$params = array_merge($params, $argv);
}
// Check calling parameters against signatures
$matched = false;
$sigCalled = $request->getTypes();
$sigLength = count($sigCalled);
$paramsLen = count($params);
if ($sigLength < $paramsLen) {
for ($i = $sigLength; $i < $paramsLen; ++$i) {
$xmlRpcValue = Zend_XmlRpc_Value::getXmlRpcValue($params[$i]);
$sigCalled[] = $xmlRpcValue->getType();
}
}
$signatures = $info->getPrototypes();
foreach ($signatures as $signature) {
$sigParams = $signature->getParameters();
if ($sigCalled === $sigParams) {
$matched = true;
break;
}
}
if (!$matched) {
require_once 'Zend/XmlRpc/Server/Exception.php';
throw new Zend_XmlRpc_Server_Exception('Calling parameters do not match signature', 623);
}
$return = $this->_dispatch($info, $params);
$responseClass = $this->getResponseClass();
return new $responseClass($return);
}
示例9: _getXmlRpcParams
/**
* Retrieve method parameters as XMLRPC values
*
* @return array
*/
protected function _getXmlRpcParams()
{
$params = array();
if (is_array($this->_xmlRpcParams)) {
foreach ($this->_xmlRpcParams as $param) {
$value = $param['value'];
$type = isset($param['type']) ? $param['type'] : Zend_XmlRpc_Value::AUTO_DETECT_TYPE;
if (!$value instanceof Zend_XmlRpc_Value) {
$value = Zend_XmlRpc_Value::getXmlRpcValue($value, $type);
}
$params[] = $value;
}
}
return $params;
}
示例10: _handle
/**
* Handle an xmlrpc call (actual work)
*
* @param Zend_XmlRpc_Request $request
* @return Zend_XmlRpc_Response
* @throws Zend_XmlRpcServer_Exception|Exception
* Zend_XmlRpcServer_Exceptions are thrown for internal errors; otherwise,
* any other exception may be thrown by the callback
*/
protected function _handle(Zend_XmlRpc_Request $request)
{
$method = $request->getMethod();
// Check for valid method
if (!isset($this->_table[$method])) {
throw new Zend_XmlRpc_Server_Exception('Method "' . $method . '" does not exist', 620);
}
$info = $this->_table[$method];
$params = $request->getParams();
$argv = $info->getInvokeArguments();
if (0 < count($argv)) {
$params = array_merge($params, $argv);
}
// Check calling parameters against signatures
$matched = false;
$sigCalled = array();
foreach ($params as $param) {
$value = Zend_XmlRpc_Value::getXmlRpcValue($param);
$sigCalled[] = $value->getType();
}
$signatures = $info->getPrototypes();
foreach ($signatures as $signature) {
$sigParams = $signature->getParameters();
$tmpParams = array();
foreach ($sigParams as $param) {
$tmpParams[] = $param->getType();
}
if ($sigCalled === $tmpParams) {
$matched = true;
break;
}
}
if (!$matched) {
throw new Zend_XmlRpc_Server_Exception('Calling parameters do not match signature', 623);
}
if ($info instanceof Zend_Server_Reflection_Function) {
$func = $info->getName();
$return = call_user_func_array($func, $params);
} elseif ($info instanceof Zend_Server_Reflection_Method && $info->system) {
// System methods
$return = $info->invokeArgs($this, $params);
} elseif ($info instanceof Zend_Server_Reflection_Method) {
// Get class
$class = $info->getDeclaringClass()->getName();
if ('static' == $info->isStatic()) {
// for some reason, invokeArgs() does not work the same as
// invoke(), and expects the first argument to be an object.
// So, using a callback if the method is static.
$return = call_user_func_array(array($class, $info->getName()), $params);
} else {
// Object methods
try {
$object = $info->getDeclaringClass()->newInstance();
} catch (Exception $e) {
throw new Zend_XmlRpc_Server_Exception('Error instantiating class ' . $class . ' to invoke method ' . $info->getName(), 621);
}
$return = $info->invokeArgs($object, $params);
}
} else {
throw new Zend_XmlRpc_Server_Exception('Method missing implementation ' . get_class($info), 622);
}
$response = new ReflectionClass($this->_responseClass);
return $response->newInstance($return);
}
示例11: file_get_contents
require_once __DIR__ . '/../vendor/autoload.php';
$start = 0;
$limit = 40;
$r = null;
$xml = file_get_contents(__DIR__ . '/response.xml');
$start = microtime(true);
for ($a = 0; $a < $limit; ++$a) {
$s = new SimpleXmlElement($xml);
$r = Zend\XmlRpc\AbstractValue::getXmlRpcValue($s->params->param->value->asXml(), Zend\XmlRpc\AbstractValue::XML_STRING);
}
$end = microtime(true);
printf("Zend\\XmlRpc\\AbstractValue (ZF2): %s sec for %d passes\n", $end - $start, $limit);
$start = microtime(true);
for ($a = 0; $a < $limit; ++$a) {
$s = new SimpleXmlElement($xml);
$r = Zend_XmlRpc_Value::getXmlRpcValue($s->params->param->value->asXml(), Zend_XmlRpc_Value::XML_STRING);
}
$end = microtime(true);
printf("Zend_XmlRpc_Value (ZF1): %s sec for %d passes\n", $end - $start, $limit);
$start = microtime(true);
$parser = new fXmlRpc\Parser\XmlReaderParser();
for ($a = 0; $a < $limit; ++$a) {
$r = $parser->parse($xml);
}
$end = microtime(true);
printf("fXmlRpc\\Parser\\XmlReaderParser: %s sec for %d passes\n", $end - $start, $limit);
$start = microtime(true);
$parser = new fXmlRpc\Parser\NativeParser();
for ($a = 0; $a < $limit; ++$a) {
$r = $parser->parse($xml);
}
示例12: sendToBitcash
/**
* sendToBitcashメソッド
*
* bitcashサーバーと通信をする
* ├カード認証
* └決済実行
*
* @param array $orderingData 注文データ
* @param string $card_number カード番號(ひらがな16文字)
*
* @return array $result ビットキャッシュからの戻り値
*
*/
function sendToBitcash($orderingData, $cardNumber)
{
if (!$orderingData or !$cardNumber) {
return FALSE;
}
$ComXmlRpcClientOBJ = new ComXmlRpcClient(self::BITCASH_URL);
try {
$ComXmlRpcClientOBJ->setSkipSystemLookup(true);
$proxy = $ComXmlRpcClientOBJ->getProxy("Settlement");
/* ■■■■■■■■■
* バリデートロジック
* ■■■■■■■■■
* ビットキャッシュ側にカード、金額データを送信して
* チェックを行う。
*/
$validateParam["SHOP_ID"] = self::BITCASH_SHOP_ID;
$validateParam["SHOP_PASSWD"] = self::BITCASH_SHOP_PASS;
$validateParam["CARD_NUMBER"] = $cardNumber;
$validateParam["RATING"] = self::BITCASH_RATING;
$validateParam["PRICE"] = $orderingData["pay_total"];
$validateParam["ORDER_ID"] = $orderingData["id"];
$validateParam = Zend_XmlRpc_Value::getXmlRpcValue($validateParam, Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT);
$validateResult = $proxy->validate_card($validateParam);
if (!$validateResult) {
$this->_errorMsg = "validate_card_false_result";
return false;
} else {
if ($validateResult["faultCode"]) {
$this->_errorMsg = "validate_card_fault_code";
return false;
}
}
/* 返り値の取得
*
*
* 1.ERRORの場合 例)カード情報が違う
* Array
* ( [STATUS] => FAIL
* [ERROR] => Array( [0] => 354:bad_card_number )
* [LOG_ID] => 43634282 //バリデーション時の入出力ID
* )
*
* 2.OKの場合
* Array
* ([BALANCE] => 100000 //バリデーション実行正常終了時のクレジット數(引き落とし前のクレジット數)
* [BCS_ID] => 1581403990 //バリデーション正常終了時に発行されるセッション番號(決済実行時に使用)
* [ERROR] => Array()
* [STATUS] => OK
* [LOG_ID] => 43634465 //バリデーション時の入出力ID
* )
*/
// 有効ではない
if ($validateResult["ERROR"]) {
$this->_errorMsg = $validateResult["ERROR"][0];
return false;
}
// 有効ではない
if ("OK" != $validateResult["STATUS"]) {
$this->_errorMsg = "validate_card_bad_status";
return false;
}
/* ■■■■■■
* 決済ロジック
* ■■■■■■
* STATUSがOKで帰ってきたらまたbitcashにデータの送信。決済を行う。
*/
$param["SHOP_ID"] = self::BITCASH_SHOP_ID;
$param["SHOP_PASSWD"] = self::BITCASH_SHOP_PASS;
$param["CARD_NUMBER"] = $cardNumber;
$param["BCS_ID"] = $validateResult["BCS_ID"];
$param["PRICE"] = $orderingData["pay_total"];
$param["ORDER_ID"] = $orderingData["id"];
$param = Zend_XmlRpc_Value::getXmlRpcValue($param, Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT);
$result = $proxy->do_settlement($param);
if (!$result) {
$this->_errorMsg = "do_settlement_false_result";
return false;
} else {
if ($result["faultCode"]) {
$this->_errorMsg = "do_settlement_fault_code";
return false;
}
}
/* 返り値の取得
*
* 1.ERRORの場合 例)BCS_ID(バリデート時に生成されるID)がない場合
* Array
//.........這裏部分代碼省略.........
示例13: _call
/**
* Executes XML-RPC request by proxying local XML-RPC client.
*
* @see Zend_XmlRpc_Client
* @param string $method
* @param array $params
* @return mixed
*/
protected function _call($method, $params = array())
{
$params = array_merge($params, array('apikey' => $this->getApiKey()));
$xmlRpcClient = $this->getXmlRpcClient();
$xmlRpcClient->setSkipSystemLookup(true);
//We will manually prepare params.
try {
$retval = $xmlRpcClient->call('grav.' . $method, array(Zend_XmlRpc_Value::getXmlRpcValue($params, Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT)));
return $retval;
} catch (Zend_XmlRpc_Client_FaultException $ex) {
require_once 'NP/Service/Gravatar/XmlRpc/Exception.php';
throw new NP_Service_Gravatar_XmlRpc_Exception($ex->getMessage());
}
}
示例14: _convertParams
/**
* Convert an array of PHP variables into XML-RPC native types represented by Zend_XmlRpc_Value objects
* If method name is given, try to use the _methodSignatures data member for type hinting,
* if not, auto convert the PHP variable types into XML-RPC types
*
* @param array $params Array of PHP varaibles and/or Zend_XmlRpc_Value objects
* The parameter is passed by reference
* @param string $methodName If set, the type hinting will be according to the parameters of this method
* @return array|null Array of Zend_XmlRpc_Value objects
*/
protected function _convertParams(&$params, $methodName = null)
{
if (!is_array($params)) {
$params = null;
return;
}
$paramsTypeHinting = $this->_getMethodParams($methodName);
/** @todo what we do if count($paramsTypeHinting) differ than count($params) ? maybe nothing */
foreach ($params as $i => &$param) {
if (!$param instanceof Zend_XmlRpc_Value) {
// Need to convert the parameter to Zend_XmlRpc_Value object
// If there is type hinting for this method, we use it, otherwise
// the convertion is done according to the PHP type
if (isset($paramsTypeHinting[$i])) {
$param = Zend_XmlRpc_Value::getXmlRpcValue($param, $paramsTypeHinting[$i]);
} else {
$param = Zend_XmlRpc_Value::getXmlRpcValue($param);
}
}
}
}
示例15: set_include_path
* $this->_xmlWriter->flush(true);
*/
// installed framework
set_include_path(realpath('../src/ZendFramework/library'));
// required classes
require_once 'Zend/XmlRpc/Generator/XmlWriter.php';
require_once 'Zend/XmlRpc/Value.php';
// be sure to use the leaky generator
$generator = new Zend_XmlRpc_Generator_XmlWriter();
Zend_XmlRpc_Value::setGenerator($generator);
// test a thousand times
for ($i = 1000; $i > 0; $i--) {
// make a thousand stars
$bug = str_pad('', 1000, '*');
// factorize value
$bug = Zend_XmlRpc_Value::getXmlRpcValue($bug, Zend_XmlRpc_Value::XMLRPC_TYPE_STRING);
// save value, this leaks!
$bug = $bug->saveXml();
// report sometimes
if ($i % 100 === 0) {
$mem = floor(memory_get_usage() / 1024);
echo "KB {$mem}\n";
}
// print once
if ($i === 1) {
echo htmlentities($bug);
}
// clean
unset($bug);
}
?>