use of com.xilixir.fortniteapi.v2.Epic.Friends.Friend in project FortniteAPI by Xilixir.
the class FortniteAPI method getFriendListData.
public Friend[] getFriendListData(String userId) throws IOException {
// request
GenericUrl url = new GenericUrl("https://friends-public-service-prod06.ol.epicgames.com/friends/api/public/friends/" + userId + "?includePending=true");
HttpRequest request = factory.buildGetRequest(url);
// headers
request.getHeaders().setAuthorization("bearer " + this.auth.getAccessToken());
String json = request.execute().parseAsString();
Friend[] friends = new Gson().fromJson(json, new TypeToken<Friend[]>() {
}.getType());
log("Retrieved friend info");
return friends;
}
use of com.xilixir.fortniteapi.v2.Epic.Friends.Friend in project FortniteAPI by Xilixir.
the class Example method main.
public static void main(String[] args) {
Configuration login = new Configuration("login", Credentials.class);
Credentials credentials = login.read();
FortniteAPI api = new FortniteAPI(credentials);
try {
api.authenticate();
} catch (IOException e) {
e.printStackTrace();
}
try {
EpicLookup lookup = api.getUserInfo("bad.player");
Friend[] friends = api.getFriendListData(lookup.getId());
for (Friend friend : friends) {
if (friend.getStatus() == Status.PENDING && friend.getDirection() == Direction.INBOUND) {
System.out.println("attempting to delete friend: " + new Gson().toJson(friend));
api.deleteFriendRequest(lookup.getId(), friend.getAccountId());
}
}
System.out.println(new Gson().toJson(friends));
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations