public static async Task <bool> VisitWorld(this VRCSharpSession session, APIWorld World, int InstanceID) { var nvc = new List <KeyValuePair <string, string> >(); nvc.Add(new KeyValuePair <string, string>("userId", "asd")); nvc.Add(new KeyValuePair <string, string>("worldId", $"{World.id}:{InstanceID.ToString()}")); var req = new HttpRequestMessage(HttpMethod.Put, "https://vrchat.com/api/1/visits") { Content = new FormUrlEncodedContent(nvc) }; HttpClientHandler handler = null; HttpClient client = new HttpClient(); if (session.UseProxies) { //Load proxies from Proxies.txt handler = new HttpClientHandler(); handler.Proxy = APIExtensions.GetRandomProxy(); client = new HttpClient(handler); } client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Add("Authorization", session.AuthToken); var response = await client.SendAsync(req); if (response.StatusCode == HttpStatusCode.OK) { APIWorldHelper.CurrentWorldID = World.id; APIWorldHelper.CurrentInstanceID = InstanceID; return(true); } else { return(false); } }
public static async Task <bool> Invite(this VRCSharpSession session, APIUser user, APIWorld world, string worldIdWithTags) { HttpClientHandler handler = null; HttpClient client = new HttpClient(); if (session.UseProxies) { //Load proxies from Proxies.txt handler = new HttpClientHandler(); handler.Proxy = APIExtensions.GetRandomProxy(); client = new HttpClient(handler); } client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Add("Authorization", session.AuthToken); var payload = JsonConvert.SerializeObject(new InvitePayload() { message = "", type = "invite", details = new Details(world, worldIdWithTags) }); var response = await client.PostAsync($"https://vrchat.com/api/1/user/{user.id}/notification?apiKey={GlobalVars.ApiKey}", new StringContent(payload, Encoding.UTF8, "application/json")); if (response.StatusCode == HttpStatusCode.OK) { return(true); } else { return(false); } }