Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.rhidlor;
- import java.io.IOException;
- import com.google.gson.Gson;
- import json.RuneScapeAPI;
- import okhttp3.OkHttpClient;
- import okhttp3.Request;
- import okhttp3.Response;
- public class Main {
- //https://apps.runescape.com/runemetrics/profile/profile?user=Rhidlor
- private static OkHttpClient client = new OkHttpClient();
- public static void main(String[] args) {
- for(String str: getUserData("Rhidlor")) {
- System.out.println(str);
- }
- }
- public static String run(String url) throws IOException {
- Request request = new Request.Builder()
- .url(url)
- .build();
- Response response = client.newCall(request).execute();
- return response.body().string();
- }
- public static String[] getUserData(String username) {
- String json = null;
- try {
- json = getJSON("https://apps.runescape.com/runemetrics/profile/profile?user=" + username);
- }catch(Exception e) {
- e.printStackTrace();
- }
- Gson gson = new Gson();
- RuneScapeAPI runescapeAPI = gson.fromJson(json, RuneScapeAPI.class);
- return new String[] {
- "Name: " + runescapeAPI.getName(),
- "Rank: " + runescapeAPI.getRank()
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement