using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; //获取房间玩家列表 public class getPlayerList : MonoBehaviour { //private void Start() //{ // GetPlayerList(); //} // 创建请求头,使用最新的 token public Dictionary CreateHeaders() { return new Dictionary { { "Authorization","Bearer "+GlobalData.ServerData.data.access_token }, {"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" } }; } // public async Task GetPlayerList() { string response = await web.SendRequest(web.URL + "/admin/companyUser/player/list", "GET", "{}", CreateHeaders()); Debug.Log("获取演练账号列表" + response); // 解析服务器返回的数据 PlayerListResponse playerListResponse = JsonConvert.DeserializeObject(response); Debug.Log(playerListResponse.data[0].UserId); Debug.Log(playerListResponse.data[0].UserName); return playerListResponse; } } //===================================================================================================================== public class PlayerListResponse : Response { public List data { get; set; } } public class PlayerListData { public string UserName { get; set; } public string Id { get; set; } public string CompanyId { get; set; } public string UserId { get; set; } public string IsAdmin { get; set; } public string Status { get; set; } public string Remark { get; set; } // 可以为null,通常使用string类型 public string DepartmentName { get; set; } public string PostName { get; set; } public string NickName { get; set; } public string CreateTime { get; set; } }