So I have this javascript function, and I want to convert it to a java function. This is the original function:
function mailExistsCheck() {
request({
uri: "https://iag.ksmobile.net/1/cgi/is_exist",
method: "POST",
headers: {
'User-Agent': "FBAndroidSDK.0.0.1", DONE
'Accept-Language': "en_US", DONE
'appid': "135301",
'ver': "3.8.20",
'sid': "17DBB0C2B30D01B590B704501A8AC054",
'sig': "lbOfPDrq0kJNvZX8eYZH9c0Mo7o",
'Host': "iag.ksmobile.net",
'Content-Type': "multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f",
'Transfer-Encoding': "chunked",
'Accept-Encoding': "gzip"
},
body: `--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f
Content-Disposition: form-data; name="cmversion"
38201849
--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f
Content-Disposition: form-data; name="name"
` + address + `
--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f`
}, (error, response, body) => {
if (error) {
console.error(error);
}
if (body.indexOf("12018") != -1) {
register();
} else {
console.error(body);
console.error("MAIL EXISTENCE CHECK FAILED!");
process.exit(1);
}
});
I'm using this library http://kevinsawicki.github.io/http-request/ to create the http request, so far I have this:
public static String mailexiste(String address) {
String contentType = HttpRequest.post("https://iag.ksmobile.net/1/cgi/is_exist")
.userAgent("FBAndroidSDK.0.0.1")
.header("Accept-Language", "en_US")
.header("appid", "135301")
.header("ver", "3.8.20")
.header("sid", "17DBB0C2B30D01B590B704501A8AC054")
.header("sig", "lbOfPDrq0kJNvZX8eYZH9c0Mo7o")
.header("Host", "iag.ksmobile.net")
.contentType("multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f")
.acceptGzipEncoding()
.contentType(); //Gets response header
return contentType;
I think I did the headers the right way, my only issue is that I'm having problems with the body part. I don't understand most of this requests, because I'm just starting now to learn this, and I would like to do the program by myself, but I'm really stuck on this part. Also, how do I do the if's in java? Thanks in advance!