Skip to main content

Load Data

Load saved game data.

URL Verification

This API uses the service-storage-api.playnanoo.com domain.

API Information

  • URL: https://service-storage-api.playnanoo.com/storage/v20221001/load
  • Method: PUT
  • Authentication Required: Yes

Request Parameters

ParameterTypeRequiredDescription
storage_keystringRequiredKey of the data to load

Response Data

FieldTypeDescription
PlayerIdstringPlayer ID
StorageKeystringKey of the saved data
StorageValuestringValue of the saved data

Code Example

void UMyGame::LoadData(const FString& StorageKey)
{
// 플레이어 정보가 포함된 요청 바디 생성
TSharedPtr<FJsonObject> Body = FPlayNANOOHelper::CreateRequestBody();
Body->SetStringField(TEXT("storage_key"), StorageKey);

// JSON 문자열 변환
FString JsonBody = FPlayNANOOHelper::ToJsonString(Body);

// HTTP 요청
TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();
Request->SetURL(TEXT("https://service-storage-api.playnanoo.com/storage/v20221001/load"));
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 PlayerId = JsonObject->GetStringField(TEXT("PlayerId"));
FString Key = JsonObject->GetStringField(TEXT("StorageKey"));
FString Value = JsonObject->GetStringField(TEXT("StorageValue"));
UE_LOG(LogTemp, Log, TEXT("데이터 조회 성공: %s = %s"), *Key, *Value);
}
}
});

Request->ProcessRequest();
}
Data Deserialization

If you saved storage_value as JSON, you can restore it to the original object using FJsonSerializer::Deserialize().

Handling Missing Data

An error is returned if there is no saved data. For new players, handle this case to set default values.