當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XML_RPC_Message::setSendEncoding方法代碼示例

本文整理匯總了PHP中XML_RPC_Message::setSendEncoding方法的典型用法代碼示例。如果您正苦於以下問題:PHP XML_RPC_Message::setSendEncoding方法的具體用法?PHP XML_RPC_Message::setSendEncoding怎麽用?PHP XML_RPC_Message::setSendEncoding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XML_RPC_Message的用法示例。


在下文中一共展示了XML_RPC_Message::setSendEncoding方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: XML_RPC_Server_system_multiCall

/**
 * Executes multiple methods in sequence and returns the results 
 * (implements http://www.xmlrpc.com/discuss/msgReader$1208)
 *
 * @return object  a new XML_RPC_Response object
 */
function XML_RPC_Server_system_multiCall($server, $msg)
{
    $dmap = $server->dmap;
    $array = $msg;
    for ($i = 0; $i < $array->getNumParams(); $i++) {
        $details = $array->getParam($i);
        if ($details->kindOf() != 'struct') {
            $resp = new XML_RPC_Response(0, $GLOBALS['XML_RPC_err']['incorrect_params'], "system_multiCall() expects _only_ struct datatypes wrapped in one array.");
        } elseif ($details->arraysize() >= 1) {
            // check if method name a string pointing to valid function
            if (!is_a($method_obj = $details->structmem('methodName'), 'XML_RPC_value') || $method_obj->kindOf() != 'scalar' || !($method = $method_obj->scalarVal()) || !strlen($function = $dmap[$method]['function'])) {
                $resp = new XML_RPC_Response(0, $GLOBALS['XML_RPC_err']['incorrect_params'], "system_multiCall() method call '{$method}' type '" . gettype($method) . "' resolves to an invalid function. Parameter or dmap configuration problem?");
            } elseif (($params = $details->structmem('params')) && (!is_a($params, 'XML_RPC_Value') || $params->kindOf() != 'array')) {
                $resp = new XML_RPC_Response(0, $GLOBALS['XML_RPC_err']['incorrect_params'], "system_multiCall() method call '{$function}' parameters container " . "is not a XML_RPC_Value type '{$GLOBALS['XML_RPC_Array']}'.");
            } elseif (preg_match("/\\bsystem_multiCall\$/i", $function)) {
                $resp = new XML_RPC_Response(0, $GLOBALS['XML_RPC_err']['incorrect_params'], "system_multiCall() must not be called recursively.");
            } else {
                // build array containing xml_rpc_value of each param
                $params_list = array();
                for ($j = 0; isset($params) && $j < $params->arraysize(); $j++) {
                    $params_list[] = $param = $params->arraymem($j);
                }
                $msg = new XML_RPC_Message($method, $params_list);
                $msg->setSendEncoding($server->encoding);
                $resp = $server->execute($function, $msg);
            }
        } else {
            $resp = new XML_RPC_Response(0, $GLOBALS['XML_RPC_err']['incorrect_params'], "system_multiCall() must be called with at" . "least the functions name as parameter 1");
        }
        // convert error to struct (multiCall Spec)
        if (!$resp->faultCode()) {
            $xml_response = array();
            $xml_response[] = $resp->value();
            $values[] = new XML_RPC_Value($xml_response, 'array');
            //$values[] = $resp->value();
        } else {
            $value = new XML_RPC_Value();
            $value->addStruct(array('faultCode' => new XML_RPC_Value($resp->faultCode(), $GLOBALS['XML_RPC_Int']), 'faultString' => new XML_RPC_Value($resp->faultString(), $GLOBALS['XML_RPC_String'])));
            $values[] = $value;
        }
    }
    $v = new XML_RPC_Value();
    $v->addArray($values);
    return new XML_RPC_Response($v);
}
開發者ID:sqall01,項目名稱:additional_plugins,代碼行數:51,代碼來源:Server.php


注:本文中的XML_RPC_Message::setSendEncoding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。