示例#1
0
 /**
  * Send a JSON-RPC message and optional parameter arguments to the server.
  *
  * Use the API functions if possible. This method remains public to support
  * changes being made to the API before this libarary can be updated.
  *
  * @param string $message
  * @param mixed $args, ...
  * @return mixed
  * @throws BitcoinClientException
  * @see xmlrpc.inc:php_xmlrpc_decode()
  */
 public function query($message)
 {
     if (!$message || empty($message)) {
         throw new BitcoinClientException("Bitcoin client query requires a message");
     }
     $msg = new jsonrpcmsg($message);
     if (func_num_args() > 1) {
         for ($i = 1; $i < func_num_args(); $i++) {
             $msg->addParam(self::query_arg_to_parameter(func_get_arg($i)));
         }
     }
     $response = $this->send($msg);
     if ($response->faultCode()) {
         throw new BitcoinClientException($response->faultString());
     }
     return php_xmlrpc_decode($response->value());
 }
示例#2
0
 /**
  * @access private
  */
 function parseRequest($data, $content_encoding = '')
 {
     $GLOBALS['_xh'] = array();
     if (!jsonrpc_parse_req($data, $this->functions_parameters_type == 'phpvals' || $this->functions_parameters_type == 'epivals', false, $content_encoding)) {
         $r = new jsonrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_request'], $GLOBALS['xmlrpcstr']['invalid_request'] . ' ' . $GLOBALS['_xh']['isf_reason']);
     } else {
         if ($this->functions_parameters_type == 'phpvals' || $this->functions_parameters_type == 'epivals' || isset($this->dmap[$GLOBALS['_xh']['method']]['parameters_type']) && $this->dmap[$GLOBALS['_xh']['method']]['parameters_type'] == 'phpvals') {
             if ($this->debug > 1) {
                 $this->debugmsg("\n+++PARSED+++\n" . var_export($GLOBALS['_xh']['params'], true) . "\n+++END+++");
             }
             $r = $this->execute($GLOBALS['_xh']['method'], $GLOBALS['_xh']['params'], $GLOBALS['_xh']['pt'], $GLOBALS['_xh']['id']);
         } else {
             // build an xmlrpcmsg object with data parsed from xml
             $m = new jsonrpcmsg($GLOBALS['_xh']['method'], 0, $GLOBALS['_xh']['id']);
             // now add parameters in
             /// @todo for more speeed, we could just substitute the array...
             for ($i = 0; $i < sizeof($GLOBALS['_xh']['params']); $i++) {
                 $m->addParam($GLOBALS['_xh']['params'][$i]);
             }
             if ($this->debug > 1) {
                 $this->debugmsg("\n+++PARSED+++\n" . var_export($m, true) . "\n+++END+++");
             }
             $r = $this->execute($m);
         }
     }
     return $r;
 }