Skip to content Skip to main navigation Skip to footer

How to send game result to your own server using webhook

1. Introduction

Our system offers a branded mini game (HTML5 game) and save the game result (score, playtime) in our system’s database.

However, some Clients want to get the game result and save it in their database.

This guide describes how the Client can get the game result from our system.

2. Overview

Basic Scenario

  1. A game player connects to the Client’s system (website or App or etc).
  2. Client’s system recognizes the player and assigns a unique ID (‘userid’) to the player.
  3. Client’s system loads a branded mini game by calling our system’s URL with the ‘userid’.
  4. The player plays the branded mini game.
  5. When the player completes the playing, our system sends the game result to the Client’s system using a webhook URL.

Setting Process

  1. Client should create a Campaign on our system’s Studio website.
  2. Client should create a program (webhook) on their server to get the game result.
  3. Client should update the webhook URL in the Campaign’s setting at “Return Game Result” section.

3. Implement

Loading a branded mini game with userid

  • Step 3 of Basic Scenario Client’s system should call the our system’s URL with the ‘userid’.
  • The ‘userid’ value should be transferred by GET method.
Parameters
NameDescriptionFormatSample
userid *unique ID for user which is created by Client’s systemAlphabet(case sensitive) + Numberwithin 20 characters.T4g4fLTaorjames
Example

The Campaign’s original URL is 

“https://branded.mini-games.io/?php=landing@8NKHT2hK&campaign_no=1”

Client’s system should call this URL to transfer the “userid” 

“https://branded.mini-games.io/?php=landing@8NKHT2hK&campaign_no=1&userid=T4g4fLTa

Creating a webhook to get the game result

  • Step 5 of Basic Scenario Client should create a program (webhook) on their server.
  • This webhook should have a URL to be accessed by our system’s server.
  • Our system sends the game result as following parameters by POST method.
Parameters 1

If the branded mini game isn’t ‘instant win’ type.

NameDescriptionSample
userid *unique ID for userT4g4fLTa or james
tx_id *unique ID for each game playing234234
time *datetime which a game player tried to play2015-04-10 06:39:23
score*score which a game player got3500
playtime *time period(seconds) which a game player played20

* means mandatory value.

Parameters 2

If the branded mini game is ‘instant win’ type.

NameDescriptionSample
userid *unique ID for userT4g4fLTa or james
tx_id *unique ID for each game playing234234
time *datetime which a game player tried to play2015-04-10 06:39:23
reward_image *reward imagehttps://branded.mini-games.io/upload/reward/f1GByiOHZZ9biLGd32jp.png
reward_item *reward itemCoffee

* means mandatory value.

Return Code

Client server has to return the result code to the our system.

Code ValueDescription
SWhen success.
FWhen failure.If you want to give the failure reason, you can add a text after “F” code.ex) “F : score is missed”
Example by PHP
// getting data
isset($_POST[‘userid’]) ? $userid = $_POST[‘userid’] : $userid = ”;
isset($_POST[‘tx_id’]) ? $tx_id = $_POST[‘tx_id’] : $tx_id = ”;
isset($_POST[‘score’]) ? $score = $_POST[‘score’] : $score = ”;
isset($_POST[‘playtime’]) ? $playtime = $_POST[‘playtime’] : $playtime = ”;
isset($_POST[‘time’]) ? $time = $_POST[‘time’] : $time = ”;
// checking validity
if (trim($score) == “”) {
    echo “F : score is missed”;
    exit;
}
if (trim($playtime) == “”) {
    echo “F : playtime is missed”;
    exit;
}
if (trim($time) == “”) {
    echo “F : time is missed”;
    exit;
}
// saving data into database
$sql  = “insert into playing_log (‘tx_id’, ‘userid’, ‘time’, ‘score’, ‘playtime’) values (‘”.$tx_id.”‘, ‘”.$userid.”‘, ‘”.$time.”‘, ‘”.$score.”‘, ‘”.$playtime.”‘);”;
//echo $sql;
// connection DB
// insert data
~~~
// result of saving
if ($result) {
    echo “S”;
}
else {
    echo “F : DB failure”;
}

Note: if the return data is in JSON format, you will need to parse it first to get the parameter value.

Input the webhook URL in campaign’s settings

  • Go to Studio website.
  • Go to Dashboard and select the campaign.
  • In the campaign’s settings, select “Return Game Result” and input the webhook URL.
Submit a query

Leave us a message