Create Table
Creates a leaderboard table.
URL Confirmation
This API uses the service-api.playnanoo.com domain.
API Information
- URL:
https://service-api.playnanoo.com/leaderboard/v20240301/table/create - Method:
PUT - Authentication Required: Yes
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Required | Table name |
| rotation | string | Required | Rotation method ("never" or "rotation") |
| rotation_timeoffset | int | Conditional | Rotation time offset (required if rotation) |
| rotation_date | string | Conditional | Rotation start date (required if rotation) |
| rotation_time | string | Conditional | Rotation start time (required if rotation) |
| rotation_period | int | Conditional | Rotation period in days (required if rotation) |
| record_type | string | Required | Record type ("highscore", "lowscore", "sum", "last") |
| record_sort_type | string | Required | Sort type ("asc", "desc") |
| record_priority | string | Required | Record priority ("Y" or "N") |
Response Data
| Field | Type | Description |
|---|---|---|
| TableId | string | Created table ID |
Code Examples
Create Periodic Rotation Leaderboard
void UMyGame::CreateWeeklyLeaderboard()
{
// 요청 데이터 생성
// 플레이어 정보가 포함된 요청 바디 생성
TSharedPtr<FJsonObject> Body = FPlayNANOOHelper::CreateRequestBody();
Body->SetStringField(TEXT("name"), TEXT("Weekly Ranking"));
Body->SetStringField(TEXT("rotation"), TEXT("rotation"));
Body->SetNumberField(TEXT("rotation_timeoffset"), 0);
Body->SetStringField(TEXT("rotation_date"), TEXT("2024-03-01"));
Body->SetStringField(TEXT("rotation_time"), TEXT("00:00:00"));
Body->SetNumberField(TEXT("rotation_period"), 7);
Body->SetStringField(TEXT("record_type"), TEXT("highscore"));
Body->SetStringField(TEXT("record_sort_type"), TEXT("desc"));
Body->SetStringField(TEXT("record_priority"), TEXT("Y"));
// JSON 문자열 변환
FString JsonBody = FPlayNANOOHelper::ToJsonString(Body);
// HTTP 요청
TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();
Request->SetURL(TEXT("https://service-api.playnanoo.com/leaderboard/v20240301/table/create"));
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 TableId = JsonObject->GetStringField(TEXT("TableId"));
UE_LOG(LogTemp, Log, TEXT("테이블 생성 성공 - ID: %s"), *TableId);
}
}
});
Request->ProcessRequest();
}
Create Permanent Leaderboard
void UMyGame::CreatePermanentLeaderboard()
{
// 요청 데이터 생성
// 플레이어 정보가 포함된 요청 바디 생성
TSharedPtr<FJsonObject> Body = FPlayNANOOHelper::CreateRequestBody();
Body->SetStringField(TEXT("name"), TEXT("All Time Best"));
Body->SetStringField(TEXT("rotation"), TEXT("never"));
Body->SetStringField(TEXT("record_type"), TEXT("highscore"));
Body->SetStringField(TEXT("record_sort_type"), TEXT("desc"));
Body->SetStringField(TEXT("record_priority"), TEXT("Y"));
// JSON 문자열 변환
FString JsonBody = FPlayNANOOHelper::ToJsonString(Body);
// HTTP 요청
TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();
Request->SetURL(TEXT("https://service-api.playnanoo.com/leaderboard/v20240301/table/create"));
Request->SetVerb(TEXT("PUT"));
FPlayNANOOHelper::SetCommonHeaders(Request, true); // 인증 토큰 포함
Request->SetContentAsString(JsonBody);
Request->OnProcessRequestComplete().BindLambda(
[](FHttpRequestPtr Req, FHttpResponsePtr Res, bool bSuccess)
{
if (bSuccess && Res.IsValid())
{
UE_LOG(LogTemp, Log, TEXT("영구 리더보드 생성 성공"));
}
});
Request->ProcessRequest();
}
Rotation Methods
- never: Permanent leaderboard without season rotation
- rotation: Leaderboard with automatic season rotation at specified intervals
Record Types
- highscore: Keep only the highest score
- lowscore: Keep only the lowest score
- sum: Sum all scores
- last: Update with the most recent score
Rotation Period
rotation_period is set in days. For example, to rotate every 7 days, set rotation_period to 7.