Skip to content

For developers: vote rewards

How to receive players’ votes on your server and give rewards automatically. Set it up in the owner cabinet, «Vote rewards».

Webhook

For every vote with a nickname for your server we send a POST with JSON (fields below). The signature is in the X-Mmohub-Signature header: sha256= and the HMAC-SHA256 of the body with your secret key. Answer 2xx and the vote is marked «delivered». On an error we retry after 1, 10 and 30 minutes. https addresses only; redirects aren’t followed.

Request body (POST, JSON)
{
  "id": 81234,
  "project": "veloria",
  "server": "veloria-x50",
  "nickname": "DarkElfRogue",
  "votedAt": "2026-09-25T14:31:18+03:00"
}
Receiving and checking the signature — PHP
<?php
// mmohub-vote.php: set https://your-site/mmohub-vote.php as the webhook address
$secret = 'mmh_your_key'; // the secret key from the owner cabinet

function giveReward(string $nickname, int $voteId): void {
    // Your delivery: a row in the game database, mail to the character, etc.
    // Give it once per $voteId (a unique key on the vote id).
    error_log("MMOHUB reward for $nickname, vote $voteId");
}

$body = file_get_contents('php://input');
$sign = 'sha256=' . hash_hmac('sha256', $body, $secret);
if (!hash_equals($sign, $_SERVER['HTTP_X_MMOHUB_SIGNATURE'] ?? '')) {
    http_response_code(401);
    exit;
}
$vote = json_decode($body, true);
if (empty($vote['test'])) { // test: true is the cabinet's test vote
    giveReward($vote['nickname'], $vote['id']);
}
http_response_code(200);
Receiving and checking the signature — Node.js
// mmohub-vote.mjs: MMOHUB_SECRET=mmh_your_key PORT=8080 node mmohub-vote.mjs (Node 18+)
import { createServer } from 'node:http';
import { createHmac, timingSafeEqual } from 'node:crypto';

const SECRET = process.env.MMOHUB_SECRET; // the secret key from the owner cabinet
const PORT = Number(process.env.PORT ?? 8080);

function giveReward(nickname, voteId) {
  // Your delivery: a row in the game database, mail to the character, etc.
  // Give it once per voteId (a unique key on the vote id).
  console.log(`MMOHUB reward for ${nickname}, vote ${voteId}`);
}

createServer((req, res) => {
  const chunks = [];
  req.on('data', (c) => chunks.push(c));
  req.on('end', () => {
    const body = Buffer.concat(chunks);
    const want = Buffer.from('sha256=' + createHmac('sha256', SECRET).update(body).digest('hex'));
    const got = Buffer.from(String(req.headers['x-mmohub-signature'] ?? ''));
    if (got.length !== want.length || !timingSafeEqual(got, want)) {
      res.writeHead(401).end();
      return;
    }
    const vote = JSON.parse(body.toString('utf8'));
    if (!vote.test) giveReward(vote.nickname, vote.id); // test: true is the cabinet's test vote
    res.writeHead(200).end();
  });
}).listen(PORT);

API

If a webhook doesn’t suit you, choose «API»: pull new votes with a GET request and mark the rewarded ones with a POST. Send the key in the Authorization: Bearer header.

Pulling votes (the «API» method)
GET  https://mmohub.gg/api/v1/rewards/votes?server=<slug>&after=<id>
POST https://mmohub.gg/api/v1/rewards/votes/<id>/delivered?server=<slug>
Authorization: Bearer <key>

Manually

The «Manually» method is a CSV export of a day’s votes from the cabinet.

Security

Check the signature of every request and never give a reward twice for one id. A vote with test: true is a test from the cabinet — don’t reward it. You can replace the key in the cabinet at any time.

Set up the reward →
Still have a question? Write to us
Cookies on MMOHUB.GG We use cookies so the site works: sign-in, settings and vote protection. With your consent, analytics too, to learn what to improve. More on the Cookies page.