当前位置: 首页>>代码示例>>PHP>>正文


PHP XML_RPC_Message::addParam方法代码示例

本文整理汇总了PHP中XML_RPC_Message::addParam方法的典型用法代码示例。如果您正苦于以下问题:PHP XML_RPC_Message::addParam方法的具体用法?PHP XML_RPC_Message::addParam怎么用?PHP XML_RPC_Message::addParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XML_RPC_Message的用法示例。


在下文中一共展示了XML_RPC_Message::addParam方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFromOrigin

/**
 * This is the core XML-RPC client it takes the parameters passed in and bundles them up
 * and sends them as an XML-RPC request to the origin server, which processes them against
 * the central database and passes the results back to this client
 *
 * @param string $function  The name of the remote origin function to be called
 * @param array  $params    An array of the parameters to be passed to the origin function
 * @return mixed            The decoded response from the origin server
 */
function getFromOrigin($function, $params)
{
    /**
     * @package    MaxDal
     * @subpackage Delivery
     * @author     Chris Nutting <chris@m3.net>
     *
     */
    $conf = $GLOBALS['_MAX']['CONF'];
    // Create an XML-RPC client to talk to the XML-RPC server
    $client = new XML_RPC_Client($conf['origin']['script'], $conf['origin']['host'], $conf['origin']['port']);
    $message = new XML_RPC_Message($function, array());
    // Add the parameters to the message
    $message->addParam(new XML_RPC_Value($params, $GLOBALS['XML_RPC_String']));
    // Send the XML-RPC message to the server
    $response = $client->send($message, $conf['origin']['timeout'], $conf['origin']['protocol']);
    if (!$response || $response->faultCode() != 0) {
        if (defined('OA_DELIVERY_CACHE_FUNCTION_ERROR')) {
            return OA_DELIVERY_CACHE_FUNCTION_ERROR;
        } else {
            return null;
        }
    } else {
        // Decode the serialized response
        $value = $response->value();
        $value = $value->scalarval();
        $value = unserialize($value);
    }
    return $value;
}
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:39,代码来源:xmlrpc.php

示例2: multicall

 /**
  * Server Function: Multi-call
  *
  * @param	mixed
  * @return	object
  */
 public function multicall($m)
 {
     // Disabled
     return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
     $parameters = $m->output_parameters();
     $calls = $parameters[0];
     $result = array();
     foreach ($calls as $value) {
         $m = new XML_RPC_Message($value[0]);
         $plist = '';
         for ($i = 0, $c = count($value[1]); $i < $c; $i++) {
             $m->addParam(new XML_RPC_Values($value[1][$i], 'string'));
         }
         $attempt = $this->_execute($m);
         if ($attempt->faultCode() !== 0) {
             return $attempt;
         }
         $result[] = new XML_RPC_Values(array($attempt->value()), 'array');
     }
     return new XML_RPC_Response(new XML_RPC_Values($result, 'array'));
 }
开发者ID:tastyigniter,项目名称:tastyigniter,代码行数:27,代码来源:Xmlrpcs.php

示例3: parseRequest

 /**
  * @return object  a new XML_RPC_Response object
  *
  * @uses XML_RPC_Message::getEncoding(), XML_RPC_Server::$encoding
  */
 function parseRequest($data = '')
 {
     global $XML_RPC_xh, $HTTP_RAW_POST_DATA, $XML_RPC_err, $XML_RPC_str, $XML_RPC_errxml, $XML_RPC_defencoding, $XML_RPC_Server_dmap;
     if ($data == '') {
         $data = $HTTP_RAW_POST_DATA;
     }
     $this->encoding = XML_RPC_Message::getEncoding($data);
     $parser_resource = xml_parser_create($this->encoding);
     $parser = (int) $parser_resource;
     $XML_RPC_xh[$parser] = array();
     $XML_RPC_xh[$parser]['cm'] = 0;
     $XML_RPC_xh[$parser]['isf'] = 0;
     $XML_RPC_xh[$parser]['params'] = array();
     $XML_RPC_xh[$parser]['method'] = '';
     $XML_RPC_xh[$parser]['stack'] = array();
     $XML_RPC_xh[$parser]['valuestack'] = array();
     $XML_RPC_xh[$parser]['max_data_len'] = strlen($data) * 2;
     $plist = '';
     // decompose incoming XML into request structure
     xml_parser_set_option($parser_resource, XML_OPTION_CASE_FOLDING, true);
     xml_set_element_handler($parser_resource, 'XML_RPC_se', 'XML_RPC_ee');
     xml_set_character_data_handler($parser_resource, 'XML_RPC_cd');
     if (!xml_parse($parser_resource, $data, 1)) {
         // return XML error as a faultCode
         $r = new XML_RPC_Response(0, $XML_RPC_errxml + xml_get_error_code($parser_resource), sprintf('XML error: %s at line %d', xml_error_string(xml_get_error_code($parser_resource)), xml_get_current_line_number($parser_resource)));
         xml_parser_free($parser_resource);
     } elseif ($XML_RPC_xh[$parser]['isf'] > 1) {
         $r = new XML_RPC_Response(0, $XML_RPC_err['invalid_request'], $XML_RPC_str['invalid_request'] . ': ' . $XML_RPC_xh[$parser]['isf_reason']);
         xml_parser_free($parser_resource);
     } else {
         xml_parser_free($parser_resource);
         $m = new XML_RPC_Message($XML_RPC_xh[$parser]['method']);
         // now add parameters in
         for ($i = 0; $i < sizeof($XML_RPC_xh[$parser]['params']); $i++) {
             // print '<!-- ' . $XML_RPC_xh[$parser]['params'][$i]. "-->\n";
             $plist .= "{$i} - " . var_export($XML_RPC_xh[$parser]['params'][$i], true) . " \n";
             $m->addParam($XML_RPC_xh[$parser]['params'][$i]);
         }
         if ($this->debug) {
             XML_RPC_Server_debugmsg($plist);
         }
         // now to deal with the method
         $methName = $XML_RPC_xh[$parser]['method'];
         if (strpos($methName, 'system.') === 0) {
             $dmap = $XML_RPC_Server_dmap;
             $sysCall = 1;
         } else {
             $dmap = $this->dmap;
             $sysCall = 0;
         }
         if (isset($dmap[$methName]['function']) && is_string($dmap[$methName]['function']) && strpos($dmap[$methName]['function'], '::') !== false) {
             $dmap[$methName]['function'] = explode('::', $dmap[$methName]['function']);
         }
         if (isset($dmap[$methName]['function']) && is_callable($dmap[$methName]['function'])) {
             // dispatch if exists
             if (isset($dmap[$methName]['signature'])) {
                 $sr = $this->verifySignature($m, $dmap[$methName]['signature']);
             }
             if (!isset($dmap[$methName]['signature']) || $sr[0]) {
                 // if no signature or correct signature
                 if ($sysCall) {
                     $r = call_user_func($dmap[$methName]['function'], $this, $m);
                 } else {
                     $r = call_user_func($dmap[$methName]['function'], $m);
                 }
                 if (!is_a($r, 'XML_RPC_Response')) {
                     $r = new XML_RPC_Response(0, $XML_RPC_err['not_response_object'], $XML_RPC_str['not_response_object']);
                 }
             } else {
                 $r = new XML_RPC_Response(0, $XML_RPC_err['incorrect_params'], $XML_RPC_str['incorrect_params'] . ': ' . $sr[1]);
             }
         } else {
             // else prepare error response
             $r = new XML_RPC_Response(0, $XML_RPC_err['unknown_method'], $XML_RPC_str['unknown_method']);
         }
     }
     return $r;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:83,代码来源:Server.php

示例4: parseRequest

 function parseRequest($data = '')
 {
     global $HTTP_RAW_POST_DATA;
     //-------------------------------------
     //  Get Data
     //-------------------------------------
     if ($data == '') {
         $data = $HTTP_RAW_POST_DATA;
     }
     //-------------------------------------
     //  Set up XML Parser
     //-------------------------------------
     $parser = xml_parser_create($this->xmlrpc_defencoding);
     $parser_object = new XML_RPC_Message("filler");
     $parser_object->xh[$parser] = array();
     $parser_object->xh[$parser]['isf'] = 0;
     $parser_object->xh[$parser]['isf_reason'] = '';
     $parser_object->xh[$parser]['params'] = array();
     $parser_object->xh[$parser]['stack'] = array();
     $parser_object->xh[$parser]['valuestack'] = array();
     $parser_object->xh[$parser]['method'] = '';
     xml_set_object($parser, $parser_object);
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
     xml_set_element_handler($parser, 'open_tag', 'closing_tag');
     xml_set_character_data_handler($parser, 'character_data');
     //xml_set_default_handler($parser, 'default_handler');
     //-------------------------------------
     //  PARSE + PROCESS XML DATA
     //-------------------------------------
     if (!xml_parse($parser, $data, 1)) {
         // return XML error as a faultCode
         $r = new XML_RPC_Response(0, $this->xmlrpcerrxml + xml_get_error_code($parser), sprintf('XML error: %s at line %d', xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser)));
         xml_parser_free($parser);
     } elseif ($parser_object->xh[$parser]['isf']) {
         return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_retrun']);
     } else {
         xml_parser_free($parser);
         $m = new XML_RPC_Message($parser_object->xh[$parser]['method']);
         $plist = '';
         for ($i = 0; $i < sizeof($parser_object->xh[$parser]['params']); $i++) {
             $plist .= "{$i} - " . print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE) . ";\n";
             $m->addParam($parser_object->xh[$parser]['params'][$i]);
         }
         if ($this->debug === TRUE) {
             echo "<pre>";
             echo "---PLIST---\n" . $plist . "\n---PLIST END---\n\n";
             echo "</pre>";
         }
         $r = $this->execute($m);
     }
     //-------------------------------------
     //  SET DEBUGGING MESSAGE
     //-------------------------------------
     if ($this->debug === TRUE) {
         $this->debug_msg = "<!-- DEBUG INFO:\n\n" . $plist . "\n END DEBUG-->\n";
     }
     return $r;
 }
开发者ID:Calico90,项目名称:codeigniter-version-scan,代码行数:58,代码来源:Xmlrpcs.php

示例5: parseRequest

 function parseRequest($data = "")
 {
     global $XML_RPC_xh, $HTTP_RAW_POST_DATA;
     global $XML_RPC_err, $XML_RPC_str, $XML_RPC_errxml, $XML_RPC_defencoding, $XML_RPC_Server_dmap;
     if ($data == "") {
         $data = $HTTP_RAW_POST_DATA;
     }
     $parser = xml_parser_create($XML_RPC_defencoding);
     $XML_RPC_xh[$parser] = array();
     $XML_RPC_xh[$parser]['isf'] = 0;
     $XML_RPC_xh[$parser]['isf_reason'] = '';
     $XML_RPC_xh[$parser]['params'] = array();
     $XML_RPC_xh[$parser]['method'] = "";
     $XML_RPC_xh[$parser]['stack'] = array();
     $XML_RPC_xh[$parser]['valuestack'] = array();
     $plist = '';
     // decompose incoming XML into request structure
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
     xml_set_element_handler($parser, "XML_RPC_se", "XML_RPC_ee");
     xml_set_character_data_handler($parser, "XML_RPC_cd");
     xml_set_default_handler($parser, "XML_RPC_dh");
     if (!xml_parse($parser, $data, 1)) {
         // return XML error as a faultCode
         $r = new XML_RPC_Response(0, $XML_RPC_errxml + xml_get_error_code($parser), sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser)));
         xml_parser_free($parser);
     } else {
         if ($XML_RPC_xh[$parser]['isf'] > 1) {
             $r = new XML_RPC_Response(0, $XML_RPC_err['invalid_request'], $XML_RPC_str['invalid_request'] . ': ' . $XML_RPC_xh[$parser]['isf_reason']);
             xml_parser_free($parser);
         } else {
             xml_parser_free($parser);
             $m = new XML_RPC_Message($XML_RPC_xh[$parser]['method']);
             // now add parameters in
             for ($i = 0; $i < sizeof($XML_RPC_xh[$parser]['params']); $i++) {
                 // print "<!-- " . $XML_RPC_xh[$parser]['params'][$i]. "-->\n";
                 $plist .= "{$i} - " . var_export($XML_RPC_xh[$parser]['params'][$i], true) . " \n";
                 @$m->addParam($XML_RPC_xh[$parser]['params'][$i]);
             }
             XML_RPC_Server_debugmsg($plist);
             // now to deal with the method
             $methName = $XML_RPC_xh[$parser]['method'];
             if (ereg("^system\\.", $methName)) {
                 $dmap = $XML_RPC_Server_dmap;
                 $sysCall = 1;
             } else {
                 $dmap = $this->dmap;
                 $sysCall = 0;
             }
             if (isset($dmap[$methName]['function'])) {
                 // dispatch if exists
                 if (isset($dmap[$methName]['signature'])) {
                     $sr = $this->verifySignature($m, $dmap[$methName]['signature']);
                 }
                 if (!isset($dmap[$methName]['signature']) || $sr[0]) {
                     // if no signature or correct signature
                     if ($sysCall) {
                         eval('$r=' . $dmap[$methName]['function'] . '($this, $m);');
                     } else {
                         eval('$r=' . $dmap[$methName]['function'] . '($m);');
                     }
                 } else {
                     $r = new XML_RPC_Response(0, $XML_RPC_err["incorrect_params"], $XML_RPC_str["incorrect_params"] . ": " . $sr[1]);
                 }
             } else {
                 // else prepare error response
                 $r = new XML_RPC_Response(0, $XML_RPC_err["unknown_method"], $XML_RPC_str["unknown_method"]);
             }
         }
     }
     return $r;
 }
开发者ID:laiello,项目名称:coopcrucial,代码行数:71,代码来源:Server.php

示例6: call

 /**
  * A method to perform a call to the OAC XML-RPC server
  *
  * @param string $methodName The RPC method name
  * @param int    $authType   Type of required authentication, see constants
  * @param array  $aParams    Array of XML_RPC_Values
  * @return mixed The returned value or PEAR_Error on error
  */
 function call($methodName, $authType, $aParams = null, $recursionLevel = 0)
 {
     $aPref = $GLOBALS['_MAX']['PREF'];
     $oMsg = new XML_RPC_Message('oac.' . $methodName);
     $oMsg->remove_extra_lines = $this->remove_extra_lines;
     $aHeader = array('protocolVersion' => OA_DAL_CENTRAL_PROTOCOL_VERSION, 'ph' => OA_Dal_ApplicationVariables::get('platform_hash'));
     if ($authType & OA_DAL_CENTRAL_AUTH_M2M) {
         if (empty($this->oCentral)) {
             MAX::raiseError('M2M authentication used with a non M2M-enabled OA_Central object');
         }
         $aHeader['accountId'] = (int) $this->oCentral->accountId;
         $aHeader['m2mPassword'] = OA_Dal_Central_M2M::getM2MPassword($this->oCentral->accountId);
         if (empty($aHeader['m2mPassword']) || isset($GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId]) && $GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId] == true) {
             // No password stored, connect!
             $result = $this->oCentral->connectM2M();
             if (PEAR::isError($result)) {
                 return $result;
             }
             $aHeader['m2mPassword'] = $result;
         }
     }
     if ($authType & OA_DAL_CENTRAL_AUTH_SSO) {
         $aHeader['ssoUsername'] = $this->ssoUsername;
         $aHeader['ssoPassword'] = $this->ssoPassword;
     }
     if ($authType & OA_DAL_CENTRAL_AUTH_CAPTCHA) {
         $aHeader['ssoCaptcha'] = isset($_REQUEST['captcha-value']) ? $_REQUEST['captcha-value'] : '';
         $aHeader['ssoCaptchaRandom'] = isset($_REQUEST['captcha-random']) ? $_REQUEST['captcha-random'] : '';
     }
     $oMsg->addParam(XML_RPC_encode($aHeader));
     if (is_array($aParams)) {
         foreach ($aParams as $oParam) {
             $oMsg->addParam($oParam);
         }
     }
     OA::disableErrorHandling();
     $oResponse = $this->oXml->send($oMsg, OAC_RPC_TIMEOUT);
     OA::enableErrorHandling();
     if (!$oResponse) {
         return new PEAR_Error('XML-RPC connection error', OA_CENTRAL_ERROR_XML_RPC_CONNECTION_ERROR);
     }
     if ($oResponse->faultCode() || $oResponse->faultString()) {
         // Deal with particular response codes at Rpc level, avoiding endless recursion
         if (!$recursionLevel) {
             switch ($oResponse->faultCode()) {
                 case OA_CENTRAL_ERROR_PLATFORM_DOES_NOT_EXIST:
                     OA::disableErrorHandling();
                     $oSync = new OA_Sync();
                     $oSync->checkForUpdates();
                     OA::enableErrorHandling();
                     return $this->call($methodName, $authType, $aParams, ++$recursionLevel);
                 case OA_CENTRAL_ERROR_ERROR_NOT_AUTHORIZED:
                     if (!($authType & OA_DAL_CENTRAL_AUTH_M2M)) {
                         break;
                     } else {
                         // Go with OA_CENTRAL_ERROR_M2M_PASSWORD_INVALID
                     }
                 case OA_CENTRAL_ERROR_M2M_PASSWORD_INVALID:
                     // OAP was asked to connect the account to get a password
                     // Set clear the password and retry (old password is in DB in case of problems with receiving new one)
                     $GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId] = true;
                     return $this->call($methodName, $authType, $aParams, ++$recursionLevel, true);
                 case OA_CENTRAL_ERROR_M2M_PASSWORD_EXPIRED:
                     $result = $this->_reconnectM2M();
                     if (PEAR::isError($result)) {
                         return $result;
                     }
                     return $this->call($methodName, $authType, $aParams, ++$recursionLevel);
             }
         }
         return new PEAR_Error($oResponse->faultString(), $oResponse->faultCode());
     }
     $ret = XML_RPC_decode($oResponse->value());
     // handling unknown server errors
     // this may happen due to difference in Java/PHP XML-RPC handling errors
     if (is_array($ret) && (isset($ret['faultCode']) || isset($ret['faultCode']))) {
         return new PEAR_Error('Unknown server error', OA_CENTRAL_ERROR_SERVER_ERROR);
     }
     return $ret;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:88,代码来源:Rpc.php


注:本文中的XML_RPC_Message::addParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。