โ๏ธGame Integration Setup Guide
Objective: To enable users to connect their game accounts to Ludo Rewards, access their rewards, and integrate with Discord.
Step 1: User Login
Action: Implement a 'Login to Ludo Rewards' button in your game's user interface.
Process: When this button is clicked, initiate an HTTP GET request to the Ludo Rewards login endpoint with the player's unique ID and customer ID.
Parameters:
playerId(Player's unique ID)customerId(Player's unique customer ID from Ludo)
Example Endpoint:
https://{ludorewards_url}/api/v1/auth?playerId=12345&customerId=67890Expected Response: The response will include
session_token,discord_user_idandplayer_idwhich is used for further authentication.
Sample Code:
document.getElementById('loginButton').addEventListener('click', function() {
const playerId = '12345'; // Replace with actual player ID
const customerId = '67890'; // Replace with actual customer ID from Ludo
const url = `https://{ludorewards_url}/api/v1/login?playerId=${playerId}&customerId=${customerId}`;
fetch(url)
.then(response => response.json())
.then(data => {
// Store sessionToken from data for further requests
const sessionToken = data.session_token;
// Handle successful login
})
.catch(error => {
// Handle errors
});
});Step 2: Checking Login Status
Action: After logging in, call the
/meendpoint to confirm the user's login status.Headers: Include the received
session_tokenin the request headers for secure authentication.Expected Response: The response includes
playerIdandid, the Ludo user ID.
Sample Code:
Step 3: Logging Out
Action: Implement a logout functionality.
Process: Call the
/logoutendpoint with the user'ssession_tokento log the user out.Headers: Include the
session_tokenin the request headers.
Sample Code:
Additional Steps:
Storing User Data: Securely store the received
session_token,playerId, andludoUserIdin your game's database.Error Handling: Implement error handling to manage scenarios where the connection process fails.
Displaying Rewards and Discord Integration: Provide options in your game's UI for users to view their rewards and check their Discord integration status.
Note: Ensure that the provided URLs, endpoints, and parameter names align with your specific implementation. Test thoroughly to ensure a smooth user experience.
Last updated