Quick start
Four steps from an approved app to rewarded users. Copy the code, change the names, and test.
Before you start
Your app must be approved. Then open your dashboard, Apps, your app, Integration. You need three values from there:
| Value | Where you use it |
|---|---|
| App ID | In the offerwall link. |
| Link hash salt | On your server, to sign the offerwall link. |
| Postback secret key | On your server, to check that postbacks come from us. |
Keep the salt and the secret key on your server. Never put them in JavaScript or in an app.
1. Show the offerwall
Build the link on your server for the signed-in user, then open it or put it in an iframe.
$userId = (string)$currentUser->id;
$hash = hash_hmac('sha256', $userId, $linkHashSalt);
$link = 'https://wall.sharklio.com/' . $appId . '?user_id=' . rawurlencode($userId) . '&hash=' . $hash;
<iframe src="LINK" width="100%" height="800" style="border:0" title="Offerwall"></iframe>
More options, and the same code in Node.js and Python: Offerwall link.
2. Add your postback URL
In the Postback tab, enter the URL of a script on your server, with the macros you want:
https://yoursite.com/sharklio-postback.php?user={user_id}&tx={transaction_id}&status={status}&reward={reward}&hash={hash}
3. Handle the postback
Check the hash, then act on the status. Every transaction keeps the same ID from start to end, so store the last status you handled.
$tx = $_GET['tx'] ?? '';
$userId = $_GET['user'] ?? '';
$reward = $_GET['reward'] ?? '0';
$status = (int)($_GET['status'] ?? 0);
$expected = hash_hmac('sha256', "$tx:$userId:$reward:$status", $postbackSecretKey);
if (!hash_equals($expected, $_GET['hash'] ?? '')) {
http_response_code(403);
exit;
}
$last = get_last_status($tx);
if ($status === 1 && $last !== 1 && $last !== 2) {
add_to_balance($userId, $reward);
save_status($tx, 1);
} elseif ($status === 2 && $last === 1) {
subtract_from_balance($userId, $reward);
save_status($tx, 2);
} elseif ($status === 3 && $last === null) {
save_status($tx, 3);
} elseif ($status === 4 && ($last === null || $last === 3)) {
save_status($tx, 4);
}
http_response_code(200);
| Status | Meaning | Your server |
|---|---|---|
1 | Credited | Add the reward. |
2 | Reversed | Take the reward back. |
3 | Pending | Nothing yet. Only sent if you turn it on. |
4 | Rejected | Nothing. The reward is 0. |
4. Test it
- Click Send test postback in the Postback tab. It sends status 1 for
test_user. - Open Logs, Postbacks in your dashboard and check that your server answered 200.
- Check that
test_usergot the reward in your system, then remove it.
If something does not work, see Testing and troubleshooting.
