Code Example

If request has no body, hash only apiSecretKey

Python

import requests
import json
import hashlib

data = {
  "appId": "gameslug",
  "username": "user001",
  "name": "MockUser",
  "returnUrl": "https://localhost",
  "lang": "en",
}

raw = json.dumps(data,separators=(',', ':'))
apiSecretKey = "T4fYpDVj8AxCe9f6gWT113li"
partnerSlug = "MOCK"
rawToHash = raw + apiSecretKey
hash = hashlib.md5(str(rawToHash).encode(‘utf-8’)).hexdigest()

url = "https://partner-api.ezg-api.com"
headers = {"Content-Type": "application/json;x-ez-seamless-hash: hash;x-ez-sealess-partner: partnerSlug"}
response = requests.post(url, headers=headers, json=data)
print("Status Code", response.status_code)
print("JSON Response ", response.json())

Node.js

import axios from 'axios';
import { createHash } from 'crypto';

const data = {
  "appId": "gameslug",
  "username": "user001",
  "name": "MockUser",
  "returnUrl": "https://localhost",
  "lang": "en",
}

const raw = JSON.stringify(data)
const apiSecretKey = "T4fYpDVj8AxCe9f6gWT113li"
const partnerSlug = "MOCK"
const rawToHash = raw + apiSecretKey
const hash = createHash('md5').update(rawToHash).digest('hex');

const url = "https://partner-api.ezg-api.com"
const headers = {
  'Content-Type': 'application/json',
  'x-ez-seamless-hash': hash,
  'x-ez-sealess-partner' : partnerSlug
}

axios.post(url, data, {
    headers: headers
  })
.then((response) => {
    console.log(response.data)
})
.catch((error) => {
    console.log(error)
})

PHP

<?php
    $data = [
	"appId"=>"gameslug",
	"username"=>"user001",
        "name"=>"MockUser",
        "returnUrl"=>"https://localhost",
        "lang"=>"en",
    ];
    $raw = json_encode($data,JSON_UNESCAPED_SLASHES);
    $apiSecretKey = "T4fYpDVj8AxCe9f6gWT113li";
    $partnerSlug = "MOCK";
    $rawToHash = $raw . $apiSecretKey;
    $hash = md5($rawToHash);
    
    $url = 'https://partner-api.ezg-api.com';
    $ch = curl_init($url);
    $headers = [];
    $headers[] = 'Content-Type:application/json';
    $headers[] = 'x-ez-seamless-hash:'.$hash;
    $headers[] = 'x-ez-sealess-partner:'.$partnerSlug;
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    curl_close($ch);
    print_r($result);

Last updated