Exemple #1
0
 public static function execute($requests)
 {
     $jsonRpcRequest = array();
     foreach ($requests as $request) {
         $parameters = array();
         foreach ($request->getParameters() as $parameterName => $parameterVal) {
             $parameters[$parameterName] = $parameterVal['value'];
         }
         $jsonRpcRequest[] = array('id' => $request->getBatchKey(), 'method' => $request->getRpcName(), 'params' => $parameters, 'apiVersion' => 'v1');
     }
     $httpRequest = new apiHttpRequest($request->getRpcPath());
     $httpRequest->setHeaders(array('Content-Type: application/json'));
     $httpRequest->setMethod('POST');
     $httpRequest->setPostBody(json_encode($jsonRpcRequest));
     $httpRequest = $request->getIo()->authenticatedRequest($httpRequest);
     if (($decodedResponse = json_decode($httpRequest->getResponseBody(), true)) != false) {
         $ret = array();
         foreach ($decodedResponse as $response) {
             $ret[$response['id']] = self::checkNextLink($response['result']);
         }
         return $ret;
     } else {
         throw new apiServiceException("Invalid json returned by the json-rpc end-point");
     }
 }