Save Data
Save player's game data to the cloud.
URL Verification
This API uses the service-storage-api.playnanoo.com domain.
API Information
- URL:
https://service-storage-api.playnanoo.com/storage/v20221001/save - Method:
PUT - Authentication Required: Yes
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| storage_key | string | Required | Key of the data to save |
| storage_value | string | Required | Value of the data to save (JSON string possible) |
| isPrivate | string | Required | Data access restriction setting (on/off) |
Response Data
| Field | Type | Description |
|---|---|---|
| Status | string | Processing status |
Code Example
void UMyGame::SaveData(const FString& StorageKey, const FString& StorageValue, bool bIsPrivate)
{
// 플레이어 정보가 포함된 요청 바디 생성
TSharedPtr<FJsonObject> Body = FPlayNANOOHelper::CreateRequestBody();
Body->SetStringField(TEXT("storage_key"), StorageKey);
Body->SetStringField(TEXT("storage_value"), StorageValue);
Body->SetStringField(TEXT("isPrivate"), bIsPrivate ? TEXT("on") : TEXT("off"));
// JSON 문자열 변환
FString JsonBody = FPlayNANOOHelper::ToJsonString(Body);
// HTTP 요청
TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();
Request->SetURL(TEXT("https://service-storage-api.playnanoo.com/storage/v20221001/save"));
Request->SetVerb(TEXT("PUT"));
FPlayNANOOHelper::SetCommonHeaders(Request, true); // 인증 토큰 포함
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("데이터 저장 성공: %s"), *Status);
}
}
});
Request->ProcessRequest();
}
Data Format
Since storage_value is a string, it is recommended to serialize complex data structures as JSON before saving.