<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <% //GOP.gov Anywhere API HTTP POST Call, JSP Implementation //House Republican Conference, Office of Chairman Mike Pence //Thursday, January 22, 2008 try { //Basic Information String api_token = "YOUR API TOKEN HERE" String method = "METHOD GOES HERE" //For a list of available methods, go to www.gop.gov/api //To get your GOP.gov Anywhere API Token, go to www.gop.gov/portfolio/apitoken //Parameters of the Call String calldata = "api_token=" + api_token + "¶meter=data¶meter2=data2"; //Required parameters for each method can be found at www.gop.gov/api //Send the call to the method URL url = new URL("http://www.gop.gov/api/"+ method); URLConnection conn = url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(calldata); wr.flush(); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = rd.readLine()) != null) { // Process line... } wr.close(); rd.close(); } catch (Exception e) { } %>