Skip to content

Instantly share code, notes, and snippets.

View TobiasBerg's full-sized avatar
🎮

Tobias Berg TobiasBerg

🎮
View GitHub Profile
IEnumerator UpdatePlayerStorage()
{
Debug.Log("Updating player color with player storage");
using (UnityWebRequest webRequest = UnityWebRequest.Post(LootLocker.baseUrl + "v1/player/storage", ""))
{
// Set the header to authenticate the request, using our session token
webRequest.SetRequestHeader("x-session-token", this.sessionToken);
// Set header to let the server know we are sending JSON
IEnumerator GetPlayerStorage()
{
Debug.Log("Getting player storage");
using (UnityWebRequest webRequest = UnityWebRequest.Get(LootLocker.baseUrl + "v1/player/storage"))
{
// Set the header to authenticate the request
webRequest.SetRequestHeader("x-session-token", this.sessionToken);
// Send request and wait for the response
IEnumerator Login()
{
if (loginStarted)
{
loginDone = true;
loginFailed = true;
Debug.Log("Multiple calls to login detected. Rejected attempt.");
}
else
{
public class LootLocker : MonoBehaviour
{
// Configuration
private string LootLockerAPIKey = ""; // Found in settings @ my.lootlocker.io
private string PlayerIdentifier = ""; // In this case, your 64-bit steam ID - Looks like this: 76561298123001763 (Use https://steamid.io/lookup to find it)
private string baseUrl = "https://api.lootlocker.io/game/v1/";
// State
private bool loginDone = false;
private bool loginStarted = false;
@TobiasBerg
TobiasBerg / WriterPlayerStorage.sh
Created January 22, 2021 12:29
Bash Write Player Storage Example
curl -X POST 'https://api.lootlocker.io/game/v1/player/storage' \
-H 'Content-Type: application/json' \
-H 'x-session-token: your session token' \
-d '[{
"order": 1,
"key": "characterColor",
"value": "0,193,82"
}]'
@TobiasBerg
TobiasBerg / GetPlayerStorage.sh
Created January 22, 2021 12:29
Bash Get Player Storage Example
curl -X GET 'https://api.lootlocker.io/game/v1/player/storage' \
-H 'x-session-token: your session token'
@TobiasBerg
TobiasBerg / Auth.sh
Created January 22, 2021 12:28
Bash Authenticate Example
curl -X POST 'https://api.lootlocker.io/game/v2/session' \
-H 'Content-Type: application/json' \
-d '{
"game_key": "your game api key",
"platform": "ios",
"player_identifier": "93c2e0e2-e399-41a1-af86-a9e1d0189b77",
"game_version": "1.0.0",
"development_mode": "false"
}
@TobiasBerg
TobiasBerg / WriterPlayerStorage.c
Last active January 22, 2021 12:27
C Write Player Storage
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.lootlocker.io/game/v1/player/storage");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
@TobiasBerg
TobiasBerg / GetPlayerStorage.c
Created January 22, 2021 12:23
C Get Player Storage Example
var client = new RestClient("https://api.lootlocker.io/game/v1/player/storage");
var request = new RestRequest(Method.GET);
request.AddHeader("x-session-token", "your session token");
IRestResponse response = client.Execute(request);
@TobiasBerg
TobiasBerg / Auth.c
Created January 22, 2021 12:22
C Authenticate Example
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.lootlocker.io/game/v2/session");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;