Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try { // Create a URL and open a connection
- String url = "https://api.fortnitetracker.com/v1/profile/psn/GOPJ1";
- URL FortniteURL = new URL(url);
- HttpURLConnection urlConnection =
- (HttpURLConnection) FortniteURL.openConnection();
- // Set the paramters for the HTTP Request
- urlConnection.setRequestMethod("GET");
- urlConnection.setConnectTimeout(10000);
- urlConnection.setReadTimeout(10000);
- urlConnection.setRequestProperty("TRN-Api-Key", "MY KEY HERE");
- // Create an input stream and wrap in a BufferedReader to read the
- // response.
- BufferedReader in =
- new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
- String inputLine;
- StringBuilder response = new StringBuilder();
- while ((inputLine = in.readLine()) != null) {
- response.append(inputLine);
- }
- // MAKE SURE TO CLOSE YOUR CONNECTION!
- in.close();
- // response is the contents of the XML
- System.out.println(response);
- System.out.println();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement