Getting Started

Getting started

In order to integrate the Rewarded Media experience, a signed URL must be generated that a user is sent to in order for them to view the promotion that a user will interact.

The minimum information that is required is:

  • User ID (string) - This is used for tracking purposes and will be sent back through the webhook so you can credit the correct user
  • Timestamp (integer) - A real-time signing timestamp
  • Signed Hash (string) - Used for server-side verification

Building the URL that the user will navigate to to get started

The base URL that the user will be redirected to will be provided to you and will look something like: https://rewardedmedia.com/api/promo/UNIQUE_HASH

const baseURL = 'https://rewardedmedia.com/api/promo/UNIQUE_HASH';
const memberId = 'abc123';
const sharedSecretKey = 'secretKeyThatShouldNotBeStoredInPlaintext';
const timestamp = Date.now()/1000;
const data = `${memberId}~${sharedSecretKey}~${timestamp}`;

// use the prefered crypto method of your choice
const signedHash = sha256(data);

const redirectURL = `${baseURL}?uid=${memberId}&ts=${timestamp}&sig=${signedHash}`
<?php
$baseURL = 'https://rewardedmedia.com/api/promo/UNIQUE_HASH';
$memberId = 'abc123';
$sharedSecretKey = 'secretKeyThatShouldNotBeStoredInPlaintext';
$timestamp = time();
$data = $memberId . '~' . $sharedSecretKey . '~' . $timestamp;
$signedHash = hash('sha256', $data);

$redirectURL = $baseURL . '?uid=' . $memberId . '&ts=' . $timestamp . '&sig=' . $signedHash;
echo $redirectURL;
?>
import hashlib
import time

base_url = 'https://rewardedmedia.com/api/promo/UNIQUE_HASH'
member_id = 'abc123'
shared_secret_key = 'secretKeyThatShouldNotBeStoredInPlaintext'
timestamp = int(time.time())

data = f"{member_id}~{shared_secret_key}~{timestamp}"
signed_hash = hashlib.sha256(data.encode()).hexdigest()

redirect_url = f"{base_url}?uid={member_id}&ts={timestamp}&sig={signed_hash}"
print(redirect_url)
package main

import (
    "crypto/sha256"
    "encoding/hex"
    "fmt"
    "strconv"
    "time"
)

func main() {
    baseURL := "https://rewardedmedia.com/api/promo/UNIQUE_HASH"
    memberId := "abc123"
    sharedSecretKey := "secretKeyThatShouldNotBeStoredInPlaintext"
    timestamp := time.Now().Unix()

    data := memberId + "~" + sharedSecretKey + "~" + strconv.FormatInt(timestamp, 10)
    hasher := sha256.New()
    hasher.Write([]byte(data))
    signedHash := hex.EncodeToString(hasher.Sum(nil))

    redirectURL := fmt.Sprintf("%s?uid=%s&ts=%d&sig=%s", baseURL, memberId, timestamp, signedHash)
    fmt.Println(redirectURL)
}

Receiving a ping when the user should be rewarded

Once the user has earned enough credits for a payout, we will pass over a link to your server through a server-side request.

The minimum information available will be:

  • User ID (string) - The unique identifier passed over during the initial request
  • Timestamp (integer) - A unix timestamp in seconds
  • Value Earned (integer) - The value in the denomination of currency set, e.g. 1 = $0.01
  • Signed Hash (string) - Used for server-side verification

For more details on how the webhook works, see the OnCompletion Webhook documentation.