按名称搜索公会
按公会名称搜索的 API。
URL 确认
此 API 使用 service-api.playnanoo.com 域名。
API 信息
- URL:
https://service-api.playnanoo.com/guild/v20230101/search/name - Method:
PUT - 需要认证: 是
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| table_code | string | 必填 | 表代码 |
| name | string | 必填 | 要搜索的公会名称 |
DeviceInfo 继承
此 API 的 Req 类继承自 DeviceInfo。DeviceInfo 的所有属性将自动包含。
响应数据
Res 类
| 字段 | 类型 | 说明 |
|---|---|---|
| Items | List\<SearchItemModel> | 公会列表 |
SearchItemModel 结构
| 字段 | 类型 | 说明 |
|---|---|---|
| TableCode | string | 表代码 |
| Uid | string | 公会唯一 ID |
| Name | string | 公会名称 |
| Point | double | 公会积分 |
| MasterUuid | string | 会长 UUID |
| MasterNickname | string | 会长昵称 |
| Country | string | 国家代码 |
| MemberCount | int | 当前成员数 |
| MemberLimit | int | 成员限制数 |
| AutoJoin | string | 自动加入 |
| ExtraData | string | 附加数据 |
| InDate | string | 公会创建日期 |
Unity C# 实现
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class GuildSearchName
{
static string path = "https://service-api.playnanoo.com/guild/v20230101/search/name";
[Serializable]
public class Req : DeviceInfo
{
public string table_code;
public string name;
public IEnumerator Send(
string tableCode,
string name,
Action<Res> onSuccess,
Action<BaseResponse> onError
)
{
if (!string.IsNullOrEmpty(tableCode)) this.table_code = tableCode;
if (!string.IsNullOrEmpty(name)) this.name = name;
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public List<SearchItemModel> Items;
}
[Serializable]
public class SearchItemModel
{
public string TableCode;
public string Uid;
public string Name;
public double Point;
public string MasterUuid;
public string MasterNickname;
public string Country;
public int MemberCount;
public int MemberLimit;
public string AutoJoin;
public string ExtraData;
public string InDate;
}
}
使用示例
public void SearchGuildByName()
{
GuildSearchName.Req req = new GuildSearchName.Req();
StartCoroutine(req.Send(
tableCode: "guild_table",
name: "MyGuild",
onSuccess: res =>
{
foreach (var item in res.Items)
{
Debug.Log($"Uid: {item.Uid}, Name: {item.Name}");
Debug.Log($"Point: {item.Point}, MemberCount: {item.MemberCount}/{item.MemberLimit}");
Debug.Log($"Master: {item.MasterNickname}");
}
},
onError: (error) =>
{
Debug.LogError($"길드 검색 실패: [{error.ErrorCode}] {error.Message}");
}
));
}