查询表
用于查询排行榜表信息的 API。
URL 确认
此 API 使用 service-api.playnanoo.com 域名。
API 信息
- URL:
https://service-api.playnanoo.com/leaderboard/v20240301/table/show - Method:
PUT - 需要认证: 是
DeviceInfo 继承
此 API 的 Req 类继承自 DeviceInfo。DeviceInfo 的所有属性会自动包含。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| uid | string | 必填 | 表代码 |
响应数据
Res 类
| 字段 | 类型 | 说明 |
|---|---|---|
| Rotation | string | 循环方式 |
| RotationCount | int | 当前赛季编号 |
| RotationTimeLeft | int | 赛季结束剩余时间(秒) |
| RecordType | string | 记录类型 |
| RecordSortType | string | 排序类型 |
| TotalIds | double | 总记录数 |
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 TableShow
{
static string path = "https://service-api.playnanoo.com/leaderboard/v20240301/table/show";
[Serializable]
public class Req : DeviceInfo
{
public string uid;
public IEnumerator Send(string table_code, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(table_code)) this.uid = table_code;
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public string Rotation;
public int RotationCount;
public int RotationTimeLeft;
public string RecordType;
public string RecordSortType;
public double TotalIds;
}
}
使用示例
public void ShowLeaderboardTable()
{
TableShow.Req req = new TableShow.Req();
StartCoroutine(req.Send(
table_code: "my_leaderboard_table",
onSuccess: res =>
{
Debug.Log("테이블 조회 성공");
Debug.Log($"순환 방식: {res.Rotation}");
Debug.Log($"현재 시즌: {res.RotationCount}");
Debug.Log($"시즌 종료까지 남은 시간: {res.RotationTimeLeft}초");
Debug.Log($"기록 타입: {res.RecordType}");
Debug.Log($"정렬 타입: {res.RecordSortType}");
Debug.Log($"총 기록 수: {res.TotalIds}");
// 시즌 종료까지 남은 시간을 사용자에게 표시
TimeSpan timeLeft = TimeSpan.FromSeconds(res.RotationTimeLeft);
Debug.Log($"시즌 종료까지: {timeLeft.Days}일 {timeLeft.Hours}시간 {timeLeft.Minutes}분");
},
onError: error =>
{
Debug.LogError($"테이블 조회 실패: [{error.ErrorCode}] {error.Message}");
}
));
}
表信息
通过此 API 可以确认排行榜的当前设置和状态。可以获取赛季是否即将结束、当前有多少玩家参与等信息。
赛季计时器
可以使用 RotationTimeLeft 在 UI 中显示赛季结束倒计时。通过此功能,玩家可以了解赛季何时结束。