跳转到主要内容

按名称搜索公会

按公会名称搜索的 API。

URL 确认

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

API 信息

  • URL: https://service-api.playnanoo.com/guild/v20230101/search/name
  • Method: PUT
  • 需要认证: 是

请求参数

参数类型必填说明
table_codestring必填表代码
namestring必填要搜索的公会名称
DeviceInfo 继承

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

响应数据

Res 类

字段类型说明
ItemsList\<SearchItemModel>公会列表

SearchItemModel 结构

字段类型说明
TableCodestring表代码
Uidstring公会唯一 ID
Namestring公会名称
Pointdouble公会积分
MasterUuidstring会长 UUID
MasterNicknamestring会长昵称
Countrystring国家代码
MemberCountint当前成员数
MemberLimitint成员限制数
AutoJoinstring自动加入
ExtraDatastring附加数据
InDatestring公会创建日期

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}");
}
));
}