public APIRequest RequestFilteredMatches(string APIKey, string PlatformRegion, string filterstring) { APIStatus status = new APIStatus(); APIRequest APIRequest = new APIRequest(); if (status.bIsOnline) { try { string APIURL = "https://api.playbattlegrounds.com/shards/" + PlatformRegion + "/matches/?" + filterstring; var webRequest = WebRequest.Create(APIURL); var HTTPAPIRequest = (HttpWebRequest)webRequest; HTTPAPIRequest.PreAuthenticate = true; HTTPAPIRequest.Headers.Add("Authorization", "Bearer " + APIKey); HTTPAPIRequest.Headers.Add("Access-Control-Allow-Origins", "*"); HTTPAPIRequest.Headers.Add("Access-Control-Expose-Headers", "Content-Length"); HTTPAPIRequest.Accept = "application/json"; using (var APIResponse = HTTPAPIRequest.GetResponse()) { using (var responseStream = APIResponse.GetResponseStream()) { var myStreamReader = new StreamReader(responseStream, Encoding.Default); APIRequest.JSONString = myStreamReader.ReadToEnd(); //APIRequest.Match = MatchPhraser(APIRequest.JSONString); //using (WebClient client = new WebClient()) //{ // APIRequest.Telemetry = TelemetryPhraser(client.DownloadString(APIRequest.Match.TelemetryURL)); //} return(APIRequest); } } } catch (WebException e) { APIRequest = new APIRequest { exception = e }; return(APIRequest); } } return(APIRequest); }
/// <summary> /// Requests a single user from the PUBG Developer API /// </summary> /// <param name="APIKey">The API key to use during the request</param> /// <param name="PlatformRegion">The Platform-Region to search (i.e pc-na, xbox-eu)</param> /// <param name="AccountID">The Account ID to look up (i.e account.a417e7c0271d4fc88f307e355142dc7)</param> public APIUser RequestSingleUser(string APIKey, string PlatformRegion, string AccountID) { APIStatus status = new APIStatus(); APIUser user = new APIUser(); if (status.bIsOnline) { try { string APIURL = "https://api.playbattlegrounds.com/shards/" + PlatformRegion + "/players/" + AccountID; var webRequest = WebRequest.Create(APIURL); var HTTPAPIRequest = (HttpWebRequest)webRequest; HTTPAPIRequest.PreAuthenticate = true; HTTPAPIRequest.Headers.Add("Authorization", "Bearer " + APIKey); HTTPAPIRequest.Headers.Add("Access-Control-Allow-Origins", "*"); HTTPAPIRequest.Headers.Add("Access-Control-Expose-Headers", "Content-Length"); HTTPAPIRequest.Accept = "application/json"; using (var APIResponse = HTTPAPIRequest.GetResponse()) { using (var responseStream = APIResponse.GetResponseStream()) { var myStreamReader = new StreamReader(responseStream, Encoding.Default); return(UserPhraser(myStreamReader.ReadToEnd())); } } } catch (WebException e) { user = new APIUser { WebException = e }; return(user); } } return(user); }