Skip to content

Instantly share code, notes, and snippets.

@TobiasBerg
Created January 22, 2021 12:22
Show Gist options
  • Save TobiasBerg/952d3d94d32171ae9f86500bbfe99ffa to your computer and use it in GitHub Desktop.
Save TobiasBerg/952d3d94d32171ae9f86500bbfe99ffa to your computer and use it in GitHub Desktop.
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;
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{\"game_key\": \"your game api key\",\"platform\": \"ios\",\"player_identifier\": \"743dc17f-402c-4efc-a549-4bf61f6d8b1f\",\"game_version\": \"0.10.0.0\",\"development_mode\": \"false\"}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment