Save Log
Records information occurring on the client.
URL Notice
This API uses the service-api.playnanoo.com domain.
API Information
- URL:
https://service-api.playnanoo.com/gamelog/v20220901/save - Method:
PUT - Authentication Required: Yes
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| table_code | string | Required | Table code |
| log_value | string | Required | Log data (JSON string) |
Response Data
| Field | Type | Description |
|---|---|---|
| Status | string | Processing result status |
Code Example
void UMyGame::SaveGameLog(const FString& TableCode)
{
// Create log data
TArray<TSharedPtr<FJsonValue>> ItemsArray;
TSharedPtr<FJsonObject> Log1 = MakeShareable(new FJsonObject());
Log1->SetStringField(TEXT("key"), TEXT("event_type"));
Log1->SetStringField(TEXT("value"), TEXT("level_complete"));
ItemsArray.Add(MakeShareable(new FJsonValueObject(Log1)));
TSharedPtr<FJsonObject> Log2 = MakeShareable(new FJsonObject());
Log2->SetStringField(TEXT("key"), TEXT("level"));
Log2->SetStringField(TEXT("value"), TEXT("5"));
ItemsArray.Add(MakeShareable(new FJsonValueObject(Log2)));
TSharedPtr<FJsonObject> LogsWrapper = MakeShareable(new FJsonObject());
LogsWrapper->SetArrayField(TEXT("items"), ItemsArray);
FString LogsJson;
TSharedRef<TJsonWriter<>> LogsWriter = TJsonWriterFactory<>::Create(&LogsJson);
FJsonSerializer::Serialize(LogsWrapper.ToSharedRef(), LogsWriter);
// Create request body with player information
TSharedPtr<FJsonObject> Body = FPlayNANOOHelper::CreateRequestBody();
Body->SetStringField(TEXT("table_code"), TableCode);
Body->SetStringField(TEXT("log_value"), LogsJson);
// Convert to JSON string
FString JsonBody = FPlayNANOOHelper::ToJsonString(Body);
// HTTP request
TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();
Request->SetURL(TEXT("https://service-api.playnanoo.com/gamelog/v20220901/save"));
Request->SetVerb(TEXT("PUT"));
FPlayNANOOHelper::SetCommonHeaders(Request, true); // Include auth token
Request->SetContentAsString(JsonBody);
Request->OnProcessRequestComplete().BindLambda(
[](FHttpRequestPtr Req, FHttpResponsePtr Res, bool bSuccess)
{
if (bSuccess && Res.IsValid())
{
TSharedPtr<FJsonObject> JsonObject;
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Res->GetContentAsString());
if (FJsonSerializer::Deserialize(Reader, JsonObject))
{
FString Status = JsonObject->GetStringField(TEXT("Status"));
UE_LOG(LogTemp, Log, TEXT("Game log saved successfully: %s"), *Status);
}
}
});
Request->ProcessRequest();
}
Table Code
You must create a table code in the PlayNANOO admin console before saving game logs.
Log Data Format
Log data is passed as an array of key-value pairs and is internally converted to a JSON string.