AggregatorDocumentation v1
Aggregator API · v1

PHP, Node.js & Java

Backend launch examples in PHP, Node.js, and Java, with response checks and retry guidance.

On this page

Before using these examples#

These examples send backend requests only. Replace the illustrative game ID, player, currency, and URLs with your entitled catalogue values. Reserve the starting funds and persist the idempotency key and request before dispatch. Reuse that operation record for recovery; do not generate a key inside a retry loop.

Check both HTTP status and numeric error: 0. Keep the x-request-id header. Do not expose your key or log launch URLs. These examples show request handling, not wallet persistence or automatic retries.

Launch a game#

Choose PHP, Node.js, or Java to see the same backend launch request. These are HTTP examples, not an SDK. PHP requires the cURL extension; Node.js requires native fetch; the Java fragment uses HttpClient and text blocks in your backend code.

PHP

<?php
$request = [
  'method' => 'getGame', 'lang' => 'en',
  'user_username' => 'player-1001', 'gameid' => '12/737',
  'homeurl' => 'https://operator.example/lobby',
  'cashierurl' => 'https://operator.example/cashier',
  'currency' => 'USD', 'balance' => 1000,
];
// Load this operation's previously persisted key.
$operationKey = getenv('AGGREGATOR_OPERATION_KEY');
if (!$operationKey) throw new RuntimeException('Missing operation key');
$ch = curl_init('https://aggregatornetwork.com/v1/commands');
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json',
    'X-API-Key: ' . getenv('AGGREGATOR_API_KEY'),
    'Idempotency-Key: ' . $operationKey,
  ],
  CURLOPT_POSTFIELDS => json_encode($request, JSON_THROW_ON_ERROR),
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 60,
]);
$raw = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$transportError = curl_error($ch);
curl_close($ch);
if ($raw === false) throw new RuntimeException('Reconcile: ' . $transportError);
$body = json_decode($raw, true, flags: JSON_THROW_ON_ERROR);
if ($status !== 200 || ($body['error'] ?? null) !== 0) {
  throw new RuntimeException('Launch failed; inspect the operation record');
}
$launchUrl = $body['response']; // Pass to your authorized player securely.

Recovery and wallet handling#

For a read-only Postman catalogue request, secret handling, and production prerequisites, follow the integration checklist. Postman is a request-testing tool; these PHP, Node.js, and Java examples remain backend implementations.

The gateway prepares provider authentication internally. Send only documented command fields. See validation and recovery before implementing retries. Your integration must persist wallet reservations and operation records; these examples do not implement that storage or guarantee payment settlement.