发起RPC请求

@param $reqParams

@return \PHPCasts\Http\Response|null
@throws \Exception
505029
protected function doRequest($reqParams)
    {
        Log::debug('RPC json inner request params', $reqParams);

        if ($this->method == 'GET') {
            $res = (new Client())->get($this->url, ['params' => json_encode($reqParams)]);
        } else {
            $res = (new Client())->post($this->url, [], ['params' => json_encode($reqParams)]);
        }

        Log::debug('RPC json inner request result', ['result' => $res]);

        if ($res->code() != 200) {
            Log::warning('RPC error', ['url' => $this->url, 'params' => $reqParams, 'result' => $res]);

            throw new \Exception('RPC request failed');
        }

        return json_decode($res, true);
    }
1282291
public function get($url, $params = array())
    {
        $client = new \Guzzle\Http\Client($this->_url);
        $request = $client->get($url, array(), array(
            'query' => $params
        ));
        $request->getCurlOptions()->set(CURLOPT_SSLVERSION, 1); // CURL_SSLVERSION_TLSv1
        $response = $client->send($request);
        if ($response->isSuccessful()) {
            return $response->json();
        } else {
            throw new \Exception("云片短信服务器未有效的响应请求");
        }
    }
246969
public function sendRequest($req)
    {
        $response = $this->send($req->getJSON());

        if ($response->id != $req->id) {
            throw new Clientside\Exception("Mismatched request id");
        }

        if(isset($response->error_code)) {
            throw new Clientside\Exception("{$response->error_code} {$response->error_message}", $response->error_code);
        }

        return $response->result;
    }
1042058
protected function prepareDataProvider($params = []) {
        if (!isset($params['q'])) {
            throw new Exception('Require parameter "q"!');
        }
        $data = [];
        $modelClass = $this->modelClass;
        $listMethod = $this->listMethod;
        if (!is_null($params['q'])) {
            $data['results'] = $modelClass::$listMethod($this->keyAttribute, $this->valueAttribute, "{$this->queryAttribute} like '%{$params['q']}%'", $params);
        } else {
            $data['results'] = $modelClass::$listMethod($this->keyAttribute, $this->valueAttribute, '', $params);
        }
        return $data;
    }
212989
public function process( array $reqparams, $inputstream )
	{
		if( isset( $reqparams['method'] ) ) {
			return $this->_processRequest( $reqparams );
		}

		return $this->_processStream( $inputstream );
	}
1022598
public function execute($requestParams = array()){

        $this->getQueryBuilder()->setBulkInsert($requestParams);
       
        $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::SAVE_QUERY, QueryBuilder::PARENT_ONLY);

        $this->beginTransaction();
        try{
            $result = $this->query("$query", FALSE);
      
            $this->commitTransaction();
        }catch(Exception $e){
          
            error_log($e->getMessage());
            $this->rollbackTransaction();
        }
        if(array_key_exists('locale', $requestParams)) {
            $requestParams['locale'] = $this->parseJson($requestParams['locale']);
        }
      
        return array(get_class($this->entity) => $requestParams);
    }
765509
public function execute($params)
    {
        $this->params = $params;
        $this->validate(new \Ebanx\Command\Validator($this->params));

        // Get the HTTP client from the registry
        $httpClient = \Ebanx\Config::getHttpClient();
        $client = new $httpClient();
        $client->setRequestParams($this->params)
               ->setMethod($this->method)
               ->setAction($this->action)
               ->setIgnoredStatusCodes($this->ignoredStatusCodes)
               ->setResponseType($this->_responseType);

        try {
            $source = \Ebanx\Config::getSourceData();
        } catch (\InvalidArgumentException $e) {
            $source = null;
        }

        if (!is_null($source)) {
            $client->setSource($source);
        }

        return $client->send();
    }
901601
public function create($params, $optParams = [])
    {
        if (!$params instanceof Firewall) {
            throw new InvalidParamException(Firewall::class.' is required!');
        }

        return $this->sendRequest([], [
            'restAction' => 'create',
            'postParams' => $params->toArray(),
            'getParams' => $optParams,
        ], function ($response) {
            return isset($response->data) ? new Firewall($response->data) : $response;
        });
    }
1342254
public function _execute(array $params = null)
    {
        $connection = $this->_adapter->getConnection();

        if (!$this->_stmt) {
            return false;
        }

        if ($params !== null) {
            if (!is_array($params)) {
                $params = array($params);
            }
            $error = false;
            foreach (array_keys($params) as $name) {
                if (!@oci_bind_by_name($this->_stmt, $name, $params[$name], -1)) {
                    $error = true;
                    break;
                }
            }
            if ($error) {
                /**
                 * @see Zend_Db_Adapter_Oracle_Exception
                 */
                // require_once 'Zend/Db/Statement/Oracle/Exception.php';
                throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
            }
        }

        $retval = @oci_execute($this->_stmt, $this->_adapter->_getExecuteMode());
        if ($retval === false) {
            /**
             * @see Zend_Db_Adapter_Oracle_Exception
             */
            // require_once 'Zend/Db/Statement/Oracle/Exception.php';
            throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
        }

        $this->_keys = Array();
        if ($field_num = oci_num_fields($this->_stmt)) {
            for ($i = 1; $i <= $field_num; $i++) {
                $name = oci_field_name($this->_stmt, $i);
                $this->_keys[] = $name;
            }
        }

        $this->_values = Array();
        if ($this->_keys) {
            $this->_values = array_fill(0, count($this->_keys), null);
        }

        return $retval;
    }
1119322
public function req($reqStatus, array $configs, $defaultId = false)
    {
        $key = array_search($reqStatus, $this->coll->column($configs, 'name', 'id'));
        if ($key === false) {
            $key = $defaultId;
        }

        if ($key === false) {
            $config = current($configs);
        } else {
            $config = $configs[$key];
        }

        return $config['name'];
    }
260865
public function request(string $method, ...$params) : ResponseInterface
    {
        try {
            $response = $this->client
                ->post($this->path, $this->makeJson($method, $params));

            if ($response->hasError()) {
                // throw exception on error
                throw new BadRemoteCallException($response);
            }

            return $response;
        } catch (Throwable $exception) {
            throw exception()->handle($exception);
        }
    }
982515
public function submit(RequestParameters $params)
    {
        /**
         * PHP 5.6.0 changed the way you specify the peer name for SSL context options.
         * Using "CN_name" will still work, but it will raise deprecated errors.
         */
        $peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name';
        $options = array(
            'http' => array(
                'header' => "Content-type: application/x-www-form-urlencoded\r\n",
                'method' => 'POST',
                'content' => $params->toQueryString(),
                // Force the peer to validate (not needed in 5.6.0+, but still works)
                'verify_peer' => true,
                // Force the peer validation to use www.google.com
                $peer_key => 'www.google.com',
            ),
        );
        if (null !== $this->timeout) {
            $options['http']['timeout'] = $this->timeout;
        }
        $context = stream_context_create($options);
        return file_get_contents($this->recaptchaVerifyUrl, false, $context);
    }
1069697
public function execute($requestParams = array()){

        $this->getQueryBuilder()->setValues($requestParams);
        
        $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::SAVE_QUERY, QueryBuilder::PARENT_ONLY);

        $this->beginTransaction();
        try{
            //first save into the parent table 
            $result = $this->query("$query", FALSE);
           
            if(intval($result) > 0) {
                 
                $requestParams['id'] = $result;               
                $this->saveI18nValues($result,  $requestParams, $requestParams['locale']);
                $this->saveChildTableParams($result, $requestParams);
                $this->saveOneToManyJoins($result, $requestParams);
            }elseif(array_key_exists('id', $requestParams) && intval($requestParams['id']) > 0){      
          
                if(array_key_exists('locale', $requestParams)) {
                    $this->saveI18nValues($requestParams['id'], $requestParams, $requestParams['locale']); 
                }
       
                $this->saveChildTableParams($requestParams['id'],  $requestParams);
                $this->saveOneToManyJoins($requestParams['id'],  $requestParams);
                
            }   
            $this->saveMultiRowValues($requestParams);
      
            $this->commitTransaction();
        }catch(Exception $e){
          
            error_log($e->getMessage());
            $this->rollbackTransaction();
        }
        if(array_key_exists('locale', $requestParams)) {
            $requestParams['locale'] = $this->parseJson($requestParams['locale']);
        }
      
        return array(get_class($this->entity) => $requestParams);
    }
551625
public function QPayOrderQuery($params = array()){
        /*        //入参
                $params = array();
                $params["out_trade_no"] = "20160512161914_BBC";
                $params["sub_mch_id"] = "1900005911";*/
        if (empty($params["out_trade_no"])){
            throw new Exception('商户订单号参数不能缺少' ,'OUT_TRADE_NO_MUST_INPUT');
        }
        if (empty($params["sub_mch_id"])){
            throw new Exception('sub_mch_id不能缺少' ,'FEE_TYPE');
        }

        //api调用
        $qpayApi = new QpayMchAPI('https://qpay.qq.com/cgi-bin/pay/qpay_order_query.cgi', null, 10);
        $qpayApi->setMchId('1490434181');
        $qpayApi->setMchKey('8525638f86969d1de5c51ad0494f4f13');
        $ret = $qpayApi->reqQpay($params);
        return QpayMchUtil::xmlToArray($ret);
    }
159230
public function execute($params = array(), $requestParams = array()){
      
        $deleteParams = $params;
        if(count($requestParams) > 0) {
            $deleteParams = $requestParams;
        }
        $this->beginTransaction();
        $firstResult = null;
        try{
            //first delete the child tables
            $this->deleteI18nLocales($deleteParams); 
            $this->deleteOneToOneRows($deleteParams);

            //now delete the main tables
            $this->getQueryBuilder()->where($deleteParams);
            $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::DELETE_QUERY);

            $firstResult = $this->query($query);

            $this->commitTransaction();
        }catch(Exception $e){
            $this->logger->addError($e->getMessage());
            $this->rollbackTransaction();
        }
        return $firstResult;

    }
315986
public function setParams($params = null)
    {
        if (isset($params)) {
            $this->params = (array) $params;
        } else {
            $this->params = $this->cli->parseParams($this->server->cliArgs());
        }

        return $this;
    }
874094
private function multiCall( $params = null ) {
		if ( $params && is_array( $params ) ) 
		{
			$result = array();
			$params = $params[0];
			foreach ( $params as $param ) {
				$method = $param['methodName'];
				$args = $param['params'];
				try {
					// XML-RPC specification says that non-fault results must be in a single item array
					$result[] = array( $this->call($method, $args) );
				} catch( Exception $e) {
					$result[] = ripcord::fault( $e->getCode(), $e->getMessage() );
				}
			}
			$result = xmlrpc_encode_request( null, $result, $this->outputOptions );
		} else {
			$result = xmlrpc_encode_request( 
				null, 
				ripcord::fault( -2, 'Illegal or no params set for system.multiCall'), 
				$this->outputOptions
			);
		}	
		return $result;
	}