├── init.jsp └── README /init.jsp: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.net.*; 3 | 4 | public class EncodingTest { 5 | 6 | private static int startEncodingWorkflow() { 7 | // replace ID and key with your own 8 | String userID = "ID"; 9 | String userKey = "key"; 10 | String mediaID = "1"; 11 | StringBuffer xml = new StringBuffer(); 12 | 13 | xml.append(""); 14 | xml.append(""); 15 | xml.append(""+userID+""); 16 | xml.append(""+userKey+""); 17 | xml.append("GetMediaInfo"); 18 | xml.append(""+mediaID+""); 19 | xml.append(""); 20 | 21 | URL server = null; 22 | try { 23 | String url = "http://manage.encoding.com"; 24 | System.out.println("Connecting to:"+url); 25 | server = new URL(url); 26 | } catch (MalformedURLException mfu) { 27 | mfu.printStackTrace(); 28 | return 0; 29 | } 30 | 31 | try { 32 | String sRequest = "xml=" + URLEncoder.encode(xml.toString(), "UTF8"); 33 | 34 | System.out.println("Open new connection to tunnel"); 35 | HttpURLConnection urlConnection = (HttpURLConnection) server.openConnection(); 36 | urlConnection.setRequestMethod( "POST" ); 37 | urlConnection.setDoOutput(true); 38 | urlConnection.setConnectTimeout(60000); 39 | urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 40 | 41 | BufferedWriter out = new BufferedWriter( new OutputStreamWriter( urlConnection.getOutputStream() ) ); 42 | out.write(sRequest); 43 | out.flush(); 44 | out.close(); 45 | urlConnection.connect(); 46 | InputStream is = urlConnection.getInputStream(); 47 | 48 | String str = urlConnection.getResponseMessage(); 49 | System.out.println("Response:"+urlConnection.getResponseCode()); 50 | System.out.println("Response:"+urlConnection.getResponseMessage()); 51 | StringBuffer strbuf = new StringBuffer(); 52 | byte[] buffer = new byte[1024 * 4]; 53 | try { 54 | int n = 0; 55 | while (-1 != (n = is.read(buffer))) { 56 | strbuf.append(new String(buffer, 0, n)); 57 | } 58 | is.close(); 59 | } catch (IOException ioe) { 60 | ioe.printStackTrace(); 61 | } 62 | System.out.println(strbuf.toString()); 63 | } catch (Exception exp) { 64 | exp.printStackTrace(); 65 | } 66 | return 0; 67 | } 68 | 69 | public static void main (String[] args) { 70 | startEncodingWorkflow(); 71 | } 72 | } -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Encoding.com XML API Wrappers 2 | ============== 3 | 4 | This plugin connects to the Encoding.com API for pay as you go cloud based video transcoding services. 5 | 6 | Requires a API Key and User ID from Encoding.com. 30day adn 1GB free trial available at www.encoding.com/signup 7 | 8 | Examples: 9 | import java.io.*; 10 | import java.net.*; 11 | 12 | public class EncodingTest { 13 | 14 | private static int startEncodingWorkflow() { 15 | // replace ID and key with your own 16 | String userID = "777"; 17 | String userKey = "277e0d0sdfaaa9140a27c03419f5era"; 18 | String mediaID = "70456"; 19 | StringBuffer xml = new StringBuffer(); 20 | 21 | xml.append(""); 22 | xml.append(""); 23 | xml.append(""+userID+""); 24 | xml.append(""+userKey+""); 25 | xml.append("GetMediaInfo"); 26 | xml.append(""+mediaID+""); 27 | xml.append(""); 28 | 29 | URL server = null; 30 | try { 31 | String url = "http://manage.encoding.com"; 32 | System.out.println("Connecting to:"+url); 33 | server = new URL(url); 34 | } catch (MalformedURLException mfu) { 35 | mfu.printStackTrace(); 36 | return 0; 37 | } 38 | 39 | try { 40 | String sRequest = "xml=" + URLEncoder.encode(xml.toString(), "UTF8"); 41 | 42 | System.out.println("Open new connection to tunnel"); 43 | HttpURLConnection urlConnection = (HttpURLConnection) server.openConnection(); 44 | urlConnection.setRequestMethod( "POST" ); 45 | urlConnection.setDoOutput(true); 46 | urlConnection.setConnectTimeout(60000); 47 | urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 48 | 49 | BufferedWriter out = new BufferedWriter( new OutputStreamWriter( urlConnection.getOutputStream() ) ); 50 | out.write(sRequest); 51 | out.flush(); 52 | out.close(); 53 | urlConnection.connect(); 54 | InputStream is = urlConnection.getInputStream(); 55 | 56 | String str = urlConnection.getResponseMessage(); 57 | System.out.println("Response:"+urlConnection.getResponseCode()); 58 | System.out.println("Response:"+urlConnection.getResponseMessage()); 59 | StringBuffer strbuf = new StringBuffer(); 60 | byte[] buffer = new byte[1024 * 4]; 61 | try { 62 | int n = 0; 63 | while (-1 != (n = is.read(buffer))) { 64 | strbuf.append(new String(buffer, 0, n)); 65 | } 66 | is.close(); 67 | } catch (IOException ioe) { 68 | ioe.printStackTrace(); 69 | } 70 | System.out.println(strbuf.toString()); 71 | } catch (Exception exp) { 72 | exp.printStackTrace(); 73 | } 74 | return 0; 75 | } 76 | 77 | public static void main (String[] args) { 78 | startEncodingWorkflow(); 79 | } 80 | } 81 | Copyright (c) 2009 Encoding.com Inc. 82 | --------------------------------------------------------------------------------