공용 데이터 조회
공개로 설정된 게임 데이터를 불러오는 API입니다.
URL 확인
이 API는 service-storage-api.playnanoo.com 도메인을 사용합니다.
API 정보
- URL:
https://service-storage-api.playnanoo.com/storage/v20211101/load/public - Method:
PUT - 인증 필요: 예
DeviceInfo 상속
이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.
요청 파라미터
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| storage_key | string | 필수 | 불러올 데이터의 키 |
응답 데이터
Res 클래스
| 필드 | 타입 | 설명 |
|---|---|---|
| StorageKey | string | 저장된 데이터의 키 |
| StorageValue | string | 저장된 데이터의 값 |
Unity C# 구현
BaseResponse 클래스
모든 API 응답의 기본 클래스입니다.
public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}
필드 설명:
ErrorCode: 에러 코드Message: 에러 메시지WithdrawalKey: 탈퇴 유예 상태인 경우 복구에 필요한 키 (탈퇴 유예 중인 계정만 제공)BlockKey: 차단된 계정인 경우 제공되는 키 (차단된 계정만 제공)
공용 데이터 조회 클래스
using System;
using System.Collections;
using UnityEngine.Networking;
public class StoragePublicLoad
{
static string path = "https://service-storage-api.playnanoo.com/storage/v20211101/load/public";
[Serializable]
public class Req : DeviceInfo
{
public string storage_key;
public IEnumerator Send(string storage_key, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(storage_key)) this.storage_key = storage_key;
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public string StorageKey;
public string StorageValue;
}
}
사용 예제
public void LoadPublicData()
{
StoragePublicLoad.Req req = new StoragePublicLoad.Req();
StartCoroutine(req.Send(
storage_key: "public_ranking_data",
onSuccess: res =>
{
Debug.Log("공개 데이터 불러오기 성공");
Debug.Log($"저장 키: {res.StorageKey}");
// JSON 역직렬화
var rankingData = JsonUtility.FromJson<RankingData>(res.StorageValue);
Debug.Log($"상위 플레이어 수: {rankingData.topPlayers.Length}");
},
onError: error =>
{
Debug.LogError($"데이터 불러오기 실패: [{error.ErrorCode}] {error.Message}");
}
));
}
[Serializable]
public class RankingData
{
public string[] topPlayers;
public int[] scores;
}
공개 데이터 활용
이 API는 랭킹, 공지사항, 이벤트 정보 등 모든 플레이어가 접근할 수 있는 공개 데이터를 불러올 때 사용합니다.
isPrivate 설정
데이터 저장 시 isPrivate를 false 또는 "off"로 설정한 데이터만 이 API로 불러올 수 있습니다.