To use the API, requests must be sent from a WiFi Developer Board, Raspberry Pi, or ESP32 Device with the FlipperHTTP Flash: https://github.com/jblanked/FlipperHTTP
This documentation currently only reviews the Game API, but it will soon list all of the APIs available.
name
, app_id
, author
, and description
.
// Registering a game on the FlipSocial API.
#include "flipper_http/flipper_http.h"
// Initialize HTTP
FlipperHTTP *fhttp = flipper_http_alloc();
if (fhttp)
{
fhttp->state = IDLE; // set the state to idle
// JSON payload
char *payload = "{\"app_id\": \"test_game\", \"author\": \"John Doe\", \"description\": \"This is a test game\", \"name\": \"Test Game\"}";
// POST request
flipper_http_post_request(fhttp, "https://www.flipsocial.net/api/games/register/", "{\"Content-Type\": \"application/json\"}", payload);
// Deinitialize HTTP
flipper_http_free(fhttp);
}
username
, app_id
, and score
.
// Submitting a high score to the FlipSocial API.
#include "flipper_http/flipper_http.h"
// Initialize HTTP
FlipperHTTP *fhttp = flipper_http_alloc();
if (fhttp)
{
fhttp->state = IDLE; // set the state to idle
// JSON payload
char *payload = "{\"app_id\": \"test_game\", \"score\": 1000, \"username\": \"John Doe\"}";
// POST request
flipper_http_post_request(fhttp, "https://www.flipsocial.net/api/games/submit-score/", "{\"Content-Type\": \"application/json\"}", payload);
// Deinitialize HTTP
flipper_http_free(fhttp);
}
app_id
is the game's app_id, and max_scores
is the maximum number of scores to return.
// Retrieving high scores from the FlipSocial API.
#include "flipper_http/flipper_http.h"
// Initialize HTTP
FlipperHTTP *fhttp = flipper_http_alloc();
if (fhttp)
{
fhttp->state = IDLE; // set the state to idle
// GET request
if (flipper_http_get_request(fhttp, "https://www.flipsocial.net/api/games/high-scores/test_game/10/"))
{
while (fhttp->state == RECEIVING && furi_timer_is_running(fhttp->get_timeout_timer) > 0)
{
// Wait for the request to be received
furi_delay_ms(100);
}
furi_timer_stop(fhttp->get_timeout_timer);
// Parse JSON
if (fhttp->last_response)
{
// proccess response
}
}
// Deinitialize HTTP
flipper_http_free(fhttp);
}