Skip to content
This repository was archived by the owner on Jul 28, 2020. It is now read-only.

Applifier/unity-ads-s2s-callback-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Unity Ads S2S Callback Example

A server-side example for handling Server-to-Server Redeem Callbacks for Unity Ads.

Plese keep in mind that this is not a complete example. It only works as far as testing callback functionality between the Unity Ads server and your server. It can however be used as a basis for writing your own callback scripts. See more details in the section for customizing the reward script.

Setup Instructions

Creating a secret script

  1. Open secrets/12345.inc in a text editor.
  2. Update the variable $secret with the secret md5 hash associated with your game ID. If you don't already know your secret, please contact Unity Ads Support.
  3. Then Save As using your game ID as the file name to create a new file with your changes.

Creating a callback script

  1. Open 12345.php in a text editor and update the include path to your secret script.
  2. Then Save As using your game ID as the file name to create a new file with your changes.

Customizing the reward script

  1. Open reward.inc in a text editor.

  2. If you would like to receive alerts by email, update the variable $email with the email address you would like alerts sent to. Otherwise, leave the string empty.

    Note: This assumes your hosting provider allows sending email from PHP scripts.

  3. To actually validate and reward users, you still need to write the logic for the following functions:

  4. Then Save and Quit.

Publishing to your web server

  1. Transfer the contents of the "callbacks" directory to your web server.

  2. Set permissions for the "secrets" directory to only allow user ownership access:

    $ chmod 700 secrets
    

    Important Note: As a security precaution, the "secrets" directory should be placed outside of the web visible file structure. Move the "secrets" directory to the parent directory of web visible root directory. Then update the relative path references to it within the callback scripts.

Testing the callback script

  1. Open a browser window.
  2. Enter the URL for your callback script into the address bar of the browser and press enter.
  3. You should see "Response: 202 - Test OK" on an otherwise blank page, indicating that the script is both publicly visible and working properly.

If the test is successful, contact Unity Ads Support to set the callback URL for your game ID with the URL to your callback script.

About

A server-side example for handling Server-to-Server Redeem Callbacks for Unity Ads

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages