asked on
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.async.Callback;
import com.mashape.unirest.http.exceptions.UnirestException;
import java.util.concurrent.Future;
public class WebHookAdapter {
private static Unirest unirest = new Unirest();
static String webhookEndpoint;
public static void main(String[] args) {
Future<HttpResponse<JsonNode>> future = send("ldjflksdfj");
}
public static Future send(String text) {
String json = "{\"text\" : \"" + text + "\"}";
Future<HttpResponse<JsonNode>> future;
future = unirest.post(webhookEndpoint).header("Content-Type", "application/json").body(json).asJsonAsync(new Callback<JsonNode>() {
@Override
public void completed(HttpResponse<JsonNode> httpResponse) {
}
@Override
public void failed(UnirestException e) {
}
@Override
public void cancelled() {
}
});
return future;
}
}