public async Task <WorldInstanceResponse> GetInstance(string worldId, string instanceId) { Logger.Debug(() => $"Getting world instance with world ID: {worldId} and instance ID {instanceId}"); HttpResponseMessage response = await Global.HttpClient.GetAsync($"worlds/{worldId}/{instanceId}?apiKey={Global.ApiKey}"); WorldInstanceResponse res = null; if (response.IsSuccessStatusCode) { string text = await response.Content.ReadAsStringAsync(); Logger.Debug(() => $"JSON received: {text}"); var json = JObject.Parse(text); res = new WorldInstanceResponse { id = json["id"].ToString(), name = json["name"].ToString(), privateUsers = (json["private"] is JArray) ? json["private"].Select(tk => tk.ToObject <WorldInstanceUserResponse>()).ToList() : null, friends = (json["friends"] is JArray) ? json["friends"].Select(tk => tk.ToObject <WorldInstanceUserResponse>()).ToList() : null, users = (json["users"] is JArray) ? json["users"].Select(tk => tk.ToObject <WorldInstanceUserResponse>()).ToList() : null, hidden = (json["hidden"] == null || json["hidden"].Type == JTokenType.Null) ? null : json["hidden"].ToString(), nonce = json["nonce"]?.ToString(), }; } response.Dispose(); return(res); }
static async Task Main(string[] args) { VRChatApi.VRChatApi api = new VRChatApi.VRChatApi("username", "password"); VRChatApi.Logging.LogProvider.SetCurrentLogProvider(new ColoredConsoleLogProvider()); // remote config ConfigResponse config = await api.RemoteConfig.Get(); // user api //UserResponse userNew = await api.UserApi.Register("someName", "somePassword", "*****@*****.**"); UserResponse user = await api.UserApi.Login(); //UserResponse userUpdated = await api.UserApi.UpdateInfo(user.id, null, null, null, new List<string>() { "admin_moderator", "admin_scripting_access", "system_avatar_access", "system_world_access" }); // friends //List<UserBriefResponse> friends = await api.FriendsApi.Get(0, 20, true); //NotificationResponse friendRequestResponse = await api.FriendsApi.SendRequest("usr_f8220fc0-e6f9-45ab-8d9f-ae00e8491685", api.UserApi.Username); //string friendDeletionResponse = await api.FriendsApi.DeleteFriend("usr_f8220fc0-e6f9-45ab-8d9f-ae00e8491685"); //await api.FriendsApi.AcceptFriend("usr_f8220fc0-e6f9-45ab-8d9f-ae00e8491685"); // world api var worldId = "wrld_b2d24c29-1ded-4990-a90d-dd6dcc440300"; // The great Pug WorldResponse world = await api.WorldApi.Get(worldId); //List<WorldBriefResponse> starWorlds = await api.WorldApi.Search(WorldGroups.Favorite, count: 4); List <WorldBriefResponse> scaryWorlds = await api.WorldApi.Search(keyword : "Scary", sort : SortOptions.Popularity); List <WorldBriefResponse> featuredWorlds = await api.WorldApi.Search(featured : true); WorldMetadataResponse metadata = await api.WorldApi.GetMetadata(worldId); var instances = new List <WorldInstanceResponse>(); if (world.instances.Count > 0) { foreach (WorldInstance instance in world.instances) { WorldInstanceResponse worldInst = await api.WorldApi.GetInstance(world.id, instance.id); instances.Add(worldInst); } } // avatar api AvatarResponse avatar = await api.AvatarApi.GetById("avtr_17036f54-f706-46bf-8a43-0c60564123ff"); }