Voting Check Postback
We created a simple way for you to check if someone has voted or not.
How does Incentive Voting work?
You need a script on your server which we call once someone votes for you. See the php example for a basic integration based on the default callback below.
Default callback
This method works for most of our website users. Simply pass the voter username/id along with the vote link.
- Log into your dashboard
- Place your callback url ( web accessable url of the script you created ) within your server settings.
- Let your users vote using the following url
https://www.rsps-list.com/index.php?a=in&u=[RSPS-LIST-USERNAME]&id=[PlayerID]- You can pass any of the 3 following variables within the vote link.
id=[PlayerID]orpostback=[PlayerID]orincentive=[PlayerID] - Replace
[RSPS-LIST-USERNAME]with your username on https://www.rsps-list.com. - Replace
[PlayerID]with the ID that you identify your player with.
- You can pass any of the 3 following variables within the vote link.
Dynamic callback
On some systems, you might need some more fine control or need to pass extra dynamic variables back to your callback script. In that case you could use this method.
In such a case, you can either completely drop the id, postback or incentive parameters and pass your own user parameter, or extend your link with a callback parameter.
https://www.rsps-list.com/index.php?a=in&u=[RSPS-LIST-USERNAME]&callback=[base64_encode]
- In this method you need pass a base64_encode url, which includes whatever you need in your callback url
- Replace
[RSPS-LIST-USERNAME]with your username on https://www.rsps-list.com. - Replace
[base64_encode]with a url, encoded with php'sbase64_encode()along withurlencode()to make it safe for url handling.<?php $callback_url = urlencode(base64_encode('https://mysite.com/callback_script.php?user=voter_username&extra_parameter=some_value')); echo 'https://www.rsps-list.com/index.php?a=in&u=[RSPS-LIST-USERNAME]&callback='.$callback_url;
What variables do we sent back to you?
Following variables are sent as $_POST and $_GET in both callback methods
secret- Used to validate the request came from RSPS-List. EitherTESTwhen you use our test callback page in developement, orYOUR_API_SECRETwhich you can find in your dashboard when switching into production.voted- either1to indicate a successful vote or0for a failed/duplicated one.reset- Timestamp of when the same user is allowed to vote again on our list. Either next noon or midnight.userip- Contains the voters ip.userid- If present, contains the voters username/ID as passed by you in your vote link viaid=[PlayerID]orpostback=[PlayerID]orincentive=[PlayerID].custom- If present ( see dynamic callback ), holds reference to the base64_encoded string as passed by you viacallback=[base64_encode].
PHP Example Based on default callback method
In this example we use $_POST to grab the values we send to your script. But $_GET works as well.
<?php
#Example PHP Postback Script
#RSPS-List does not take responsibility or liability for the use of this php snippet
// Your Database Connection Details
$host = 'localhost';
$db_name = '';
$db_user = '';
$db_password = '';
$connection = mysqli_connect($host, $db_user, $db_password);
mysqli_select_db($connection, $db_name);
// This is your personal secret key, as found on the RSPS-List dashboard, or the string 'TEST' in case of our Testing script
// Update accordingly to your API secret in production, or the string 'TEST' while developing using our test callback page
$my_secret = '';
// Lets validate the request is coming from RSPS-List. And if not stop here
$secret = isset($_POST['secret']) ? $_POST['secret'] : false;
if ($secret !== $my_secret)
{
exit;
}
// User
$userid = isset($_POST['userid']) ? $_POST['userid'] : null;
// User ip
$userip = isset($_POST['userip']) ? $_POST['userip'] : null;
// User voted on RSPS-List? 1 = unique vote, 0 = already voted
$valid = isset($_POST['voted']) ? (int)$_POST['voted'] : 0;
// Timestamp of when the user is allowed to vote again on our list.
// You may use this to disable the users vote button until he is allowed to vote again. Or simply display a timer.
$reset = isset($_POST['reset']) ? (int)$_POST['reset'] : 0;
// Successful vote
if (!is_null($userid) && $valid === 1)
{
// Make userid safe to use in query
$userid_sql = mysqli_real_escape_string($connection, $userid);
// Grant reward, for example points
// Also insert timestamp of next possible vote time
mysqli_query($connection, "UPDATE `users` SET `points` = `points` + 1, `next_vote` = '$reset' WHERE `user` = '$userid_sql'");
}
// Close connection
mysqli_close($connection);
?>
Test your Callback
Test your callback script to see if it works with our system.
Please note: The secret we send to validate if requests came from RSPS-List is 'TEST' in this case and not your personal API secret. ( Refer to the PHP example )
To get your API secret when you switch into production, please head to your dashboard.