HAHOOS

Problem 16.07.2022

Jul 16th, 2022 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. //Kod główny
  2. Uri url1 = new Uri("https://api.roblox.com/users/" + Id + "/onlinestatus/");
  3.                 Thread.Sleep(3500);
  4.                 string placeIdS = (string)WebRequestGET(url1)["PlaceId"];
  5.                 long placeId = long.Parse(placeIdS);
  6.  
  7. //Metoda WebRequestGET
  8.  
  9. private static dynamic WebRequestGET(Uri url)
  10.         {
  11.             try
  12.             {
  13.                 var request = WebRequest.Create(url);
  14.                 request.Method = "GET";
  15.                 request.Timeout = 10000;
  16.                 WebResponse webResponse = request.GetResponse();
  17.                 var webStream = webResponse.GetResponseStream();
  18.                 var reader = new StreamReader(webStream);
  19.                 var data = reader.ReadToEnd();
  20.                 dynamic jsonData = JObject.Parse(data);
  21.                 return jsonData;
  22.             }catch(Exception e)
  23.             {
  24.                 var window = GetConsoleWindow();
  25.                 ShowWindow(window, 1);
  26.                 Console.WriteLine($"Error occured while fetching data, if error will occur again please create issue on github{Environment.NewLine}{e.Message}");
  27.                 Console.ReadKey();
  28.                 Application.Exit();
  29.                 return null;
  30.             }
  31.            
  32.         }
Add Comment
Please, Sign In to add comment