public function createRequestData(array $payload, $method)
    {
        if (! is_string($method)) {
            throw new \InvalidArgumentException('The $method argument has to be null or of type string');
        }

        // Every JSON RPC request has a unique ID so that the request and its response can be linked.
        // WARNING: There is no absolute guarantee that this ID is unique!
        // Use this class like a singleton to ensure uniqueness.
        // Note: According to the specs of the JSON RPC protocol we can send an int or a string,
        // so uniqid() - which returns a string - should work. Unfortunately it does not.
        self::$lastId = ++self::$lastId;
        $id = self::$lastId;

        $data = [
            'jsonrpc' => self::PROTOCOL_VERSION, // Set the protocol version
            'method'  => $method, // Set the method of the JSON RPC API call
            'params'  => $payload, // Set the parameters / the payload
            'id'      => $id, // Set the ID of this request. (Omitting it would mean we do not expect a response)
        ];

        $jsonData = json_encode($data);

        return $jsonData;
    }
public function createRequestData(array $payload, $method)
    {
        if (! is_string($method)) {
            throw new \InvalidArgumentException('The $method argument has to be null or of type string');
        }

        // Every JSON RPC request has a unique ID so that the request and its response can be linked.
        // WARNING: There is no absolute guarantee that this ID is unique!
        // Use this class like a singleton to ensure uniqueness.
        // Note: According to the specs of the JSON RPC protocol we can send an int or a string,
        // so uniqid() - which returns a string - should work. Unfortunately it does not.
        self::$lastId = ++self::$lastId;
        $id = self::$lastId;

        $data = [
            'jsonrpc' => self::PROTOCOL_VERSION, // Set the protocol version
            'method'  => $method, // Set the method of the JSON RPC API call
            'params'  => $payload, // Set the parameters / the payload
            'id'      => $id, // Set the ID of this request. (Omitting it would mean we do not expect a response)
        ];

        $jsonData = json_encode($data);

        return $jsonData;
    }
public function createRequestData ( array $ payload , $ method ) { if ( ! is_string ( $ method ) ) { throw new \ InvalidArgumentException ( 'The $method argument has to be null or of type string' ) ; } // Every JSON RPC request has a unique ID so that the request and its response can be linked. // WARNING: There is no absolute guarantee that this ID is unique! // Use this class like a singleton to ensure uniqueness. // Note: According to the specs of the JSON RPC protocol we can send an int or a string, // so uniqid() - which returns a string - should work. Unfortunately it does not. self :: $ lastId = ++ self :: $ lastId ; $ id = self :: $ lastId ; $ data = [ 'jsonrpc' => self :: PROTOCOL_VERSION , // Set the protocol version 'method' => $ method , // Set the method of the JSON RPC API call 'params' => $ payload , // Set the parameters / the payload 'id' => $ id , // Set the ID of this request. (Omitting it would mean we do not expect a response) ] ; $ jsonData = json_encode ( $ data ) ; return $ jsonData ; }
Creates a request bag according to the JSON RPC protocol.
The API will be able to understand it.
The result is encoded as a JSON string.

@param array  $payload The payload / parameters of the request. Will be encoded as JSON
@param string $method  The method of the API call.
@return string
Creates a request bag according to the JSON RPC protocol . The API will be able to understand it . The result is encoded as a JSON string .