Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. // login data
  2. ObjectNode tvdbaccount = Json.newObject();
  3. tvdbaccount.put("apikey", "*****");
  4. tvdbaccount.put("username", "*****");
  5. tvdbaccount.put("userkey", "*****");
  6.  
  7. // try to login
  8. String token = "";
  9. CompletionStage<JsonNode> request = WS.url("https://api.thetvdb.com/login").post(tvdbaccount).thenApply(WSResponse::asJson);
  10.  
  11. try {
  12. JsonNode response = request.toCompletableFuture().get(5, TimeUnit.SECONDS);
  13. token = response.get("token").asText();
  14. } catch (Exception ex) {
  15. System.out.println(ex.getMessage());
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement