Overview

A simple Get request in Java

Note- Use https:// in the url.

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://unfurl.io/api/v2/preview?api_token=yourapitoken&url=https://www.google.com"))
      .build();
client.sendAsync(request, BodyHandlers.ofString())
      .thenApply(HttpResponse::body)
      .thenAccept(System.out::println)
      .join();