|
(Java) HTTPS GET using SSL/TLS
To retrieve a resource using SSL/TLS (i.e. HTTPS), simply use a URL that begins with "https://". (This applies to any Chilkat HTTP method that has a URL argument, such as QuickGetStr, GetHead, QuickDeleteStr, etc.)
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http = new CkHttp();
// Send the HTTP GET and return the content in a string.
String html = http.quickGetStr("https://www.chilkatsoft.com/helloWorld.json");
if (http.get_LastMethodSuccess() == false) {
System.out.println(http.lastErrorText());
return;
}
System.out.println(html);
}
}
|