Skip to content

Examples

School portal: game on a lesson page (no code)

<h2>Practice: mental arithmetic</h2>
<p>Beat your best score before Friday!</p>
<div style="position:relative;width:100%;aspect-ratio:16/10;">
  <iframe src="https://play.acbizglobal.net/embed/game/mental-math-sprint?key=pk_live_YOUR_KEY"
          style="position:absolute;inset:0;width:100%;height:100%;border:0;"
          allow="fullscreen" allowfullscreen loading="lazy" title="Mental Math Sprint"></iframe>
</div>

Logged-in students with verified scores (PHP backend)

<?php
// lesson.php — runs on YOUR server
$ch = curl_init("https://play.acbizglobal.net/api/v1/games/mental-math-sprint/launch");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("ACBIZ_SECRET_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(["player_id" => "student-" . $currentStudentId]),
]);
$res = json_decode(curl_exec($ch), true);
$url = $res["data"]["launch_url"] ?? null;
?>
<?php if ($url): ?>
  <iframe src="<?= htmlspecialchars($url) ?>" width="100%" height="620" style="border:0" allowfullscreen></iframe>
<?php endif; ?>

Award points when a round ends (webhook, Node/Express)

app.post("/acbiz-webhook", express.raw({ type: "application/json" }), (req, res) => {
  if (!verify(req.body.toString(), req.get("ACBIZ-Signature"), process.env.ACBIZ_WEBHOOK_SECRET)) {
    return res.sendStatus(400);
  }
  const event = JSON.parse(req.body);
  if (event.type === "game.completed" && event.data.player_verified) {
    awardPoints(event.data.player_id, Math.floor(event.data.score / 100)); // make idempotent on event.id
  }
  res.sendStatus(200);
});

Show a live "well done" message (SDK)

var game = ACBIZPlay.init({ apiKey: "pk_live_YOUR_KEY", game: "code-breaker", container: "#game", height: "auto" });
game.on("game.completed", function (e) {
  document.getElementById("msg").textContent =
    e.data.isPersonalBest ? "New personal best: " + e.data.score + "!" : "You scored " + e.data.score;
});
game.on("error", function (e) {
  if (e.data.code === "insufficient_credits") console.warn("Top up ACBIZ Play credits");
});

Monthly usage report (cron)

curl -s "https://play.acbizglobal.net/api/v1/usage?from=$(date +%Y-%m-01)&to=$(date +%F)" \
  -H "Authorization: Bearer $ACBIZ_SECRET_KEY" | jq ".data.totals"