跳转到主要内容

注册及管理

设置或更改玩家昵称的 API。

URL 确认

此 API 使用 service-account.playnanoo.com 域名。

API 信息

  • URL: https://service-account.playnanoo.com/api/v20240401/nickname/put
  • Method: PUT
  • 需要认证: 是

请求参数

参数类型必需说明
change_nicknamestring必需要设置的昵称
check_existsstring必需是否检查重复("Y":检查,"N":不检查)
platformstring必需平台(例如:"aos"、"ios")
device_idstring必需设备唯一 ID
device_modelstring必需设备型号
device_osstring必需设备 OS
device_languagestring必需设备语言(例如:"KO"、"EN")
DeviceInfo 继承

此 API 的 Req 类继承自 DeviceInfo。DeviceInfo 的所有属性将自动包含。

响应数据

Res 类

字段类型说明
Nicknamestring设置的昵称

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 NicknamePut
{
static string path = "https://service-account.playnanoo.com/api/v20240401/nickname/put";

[Serializable]
public class Req : DeviceInfo
{
public string change_nickname;
public string check_exists;

public IEnumerator Send(
string change_nickname,
bool check_exists,
Action<Res> onSuccess,
Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(change_nickname)) this.change_nickname = change_nickname;
this.check_exists = check_exists ? "Y" : "N";

yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}

[Serializable]
public class Res : BaseResponse
{
public string Nickname;
}
}

使用示例

public void SetNickname(string newNickname)
{
NicknamePut.Req req = new NicknamePut.Req();

StartCoroutine(req.Send(
change_nickname: newNickname,
check_exists: true, // 执行重复检查
onSuccess: res =>
{
Debug.Log($"닉네임 설정 완료: {res.Nickname}");
},
onError: (error) =>
{
Debug.LogError($"닉네임 설정 실패: [{error.ErrorCode}] [{error.Message}]");

if (error.ErrorCode == "NICKNAME_ALREADY_EXISTS")
{
Debug.LogError("이미 사용 중인 닉네임입니다.");
}
}
));
}
check_exists 参数
  • true(或 "Y"):执行昵称重复检查。如果昵称重复则返回错误。
  • false(或 "N"):跳过重复检查直接设置。

通常建议设置为 true 以防止重复。