플레이어 데이터 조회
다른 플레이어의 공개 데이터를 불러오는 API입니다.
URL 확인
이 API는 service-storage-api.playnanoo.com 도메인을 사용합니다.
API 정보
- URL:
https://service-storage-api.playnanoo.com/storage/v20221001/playerDataLoad - Method:
PUT - 인증 필요: 예
DeviceInfo 상속
이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.
요청 파라미터
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| player_uuid | string | 필수 | 조회할 플레이어의 UUID |
| storage_key | string | 필수 | 불러올 데이터의 키 |
응답 데이터
Res 클래스
| 필드 | 타입 | 설명 |
|---|---|---|
| PlayerId | string | 플레이어 ID |
| 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 StoragePlayerLoad
{
static string path = "https://service-storage-api.playnanoo.com/storage/v20221001/playerDataLoad";
[Serializable]
public class Req : DeviceInfo
{
public string player_uuid; // 조회할 플레이어의 UUID
public string storage_key; // 불러올 데이터의 키
public IEnumerator Send(string player_uuid, string storage_key, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(player_uuid)) this.player_uuid = player_uuid;
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 PlayerId;
public string StorageKey;
public string StorageValue;
}
}
사용 예제
public void LoadOtherPlayerData(string targetPlayerUUID)
{
StoragePlayerLoad.Req req = new StoragePlayerLoad.Req();
StartCoroutine(req.Send(
player_uuid: targetPlayerUUID,
storage_key: "public_profile",
onSuccess: res =>
{
Debug.Log("다른 플레이어 데이터 불러오기 성공");
Debug.Log($"플레이어 ID: {res.PlayerId}");
Debug.Log($"저장 키: {res.StorageKey}");
// JSON 역직렬화
var profile = JsonUtility.FromJson<PublicProfile>(res.StorageValue);
Debug.Log($"플레이어 이름: {profile.name}");
Debug.Log($"레벨: {profile.level}");
},
onError: error =>
{
Debug.LogError($"데이터 불러오기 실패: [{error.ErrorCode}] {error.Message}");
}
));
}
[Serializable]
public class PublicProfile
{
public string name;
public int level;
public string avatar;
}
공개 데이터
이 API는 다른 플레이어의 데이터를 조회하기 위한 것입니다. 랭킹, 친구 정보 등 공개적으로 공유할 데이터에만 사용하세요.
보안 주의
민감한 개인 정보는 이 방식으로 저장하지 마세요. 공개되어도 무방한 데이터만 저장해야 합니다.