Skip to content

Instantly share code, notes, and snippets.

@DJCordhose
Last active January 14, 2019 10:09
Show Gist options
  • Save DJCordhose/4608736 to your computer and use it in GitHub Desktop.
Save DJCordhose/4608736 to your computer and use it in GitHub Desktop.
Ultradox static trigger
import static com.google.appengine.api.urlfetch.FetchOptions.Builder.withDefaults;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.appengine.api.urlfetch.HTTPMethod;
import com.google.appengine.api.urlfetch.HTTPRequest;
import com.google.appengine.api.urlfetch.HTTPResponse;
import com.google.appengine.api.urlfetch.URLFetchService;
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
@SuppressWarnings("serial")
public class App_Engine_SandboxServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService();
URL url = new URL(
"http://www.ultradox.com/ultradoc/execute?id=[your Ultradoc id goes here]&action=RUN");
HTTPRequest request = new HTTPRequest(url, HTTPMethod.GET, withDefaults().setDeadline(30.0));
HTTPResponse response = urlFetchService.fetch(request);
int code = response.getResponseCode();
resp.getWriter().write(code == HttpURLConnection.HTTP_OK ? "Success" : "Error: " +code);
}
}
function trigger() {
var response = UrlFetchApp.fetch('http://www.ultradox.com/ultradoc/execute?id=[your Ultradoc id goes here]&action=RUN');
var code = response.getResponseCode();
Logger.log(code === 200 ? "Success" : "Error Code: " + code);
}
$.getJSON("http://www.ultradox.com/jsonp?id=[your Ultradoc id goes here]&action=RUN&callback=?", null,
function(response) {
var code = response.code; // "ok" or "error"
var message = response.message; // whatever the serivce has to tell you
}
);
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.logging.Logger;
public class Main {
public static void main(String[] args) throws Exception {
URL url = new URL(
"http://www.ultradox.com/ultradoc/execute?id=[your Ultradoc id goes here]&action=RUN");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
int code = connection.getResponseCode();
Logger.getLogger("StaticTrigger").info(code == HttpURLConnection.HTTP_OK ? "Success" : "Error: " +code);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment