-
Notifications
You must be signed in to change notification settings - Fork 2
Java Script that will send XML requests to encoding.com
encoding/Encoding.com-Java-API-Wrapper
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Encoding.com XML API Wrappers ============== This plugin connects to the Encoding.com API for pay as you go cloud based video transcoding services. Requires a API Key and User ID from Encoding.com. 30day adn 1GB free trial available at www.encoding.com/signup Examples: import java.io.*; import java.net.*; public class EncodingTest { private static int startEncodingWorkflow() { // replace ID and key with your own String userID = "777"; String userKey = "277e0d0sdfaaa9140a27c03419f5era"; String mediaID = "70456"; StringBuffer xml = new StringBuffer(); xml.append("<?xml version=\"1.0\"?>"); xml.append("<query>"); xml.append("<userid>"+userID+"</userid>"); xml.append("<userkey>"+userKey+"</userkey>"); xml.append("<action>GetMediaInfo</action>"); xml.append("<mediaid>"+mediaID+"</mediaid>"); xml.append("</query>"); URL server = null; try { String url = "http://manage.encoding.com"; System.out.println("Connecting to:"+url); server = new URL(url); } catch (MalformedURLException mfu) { mfu.printStackTrace(); return 0; } try { String sRequest = "xml=" + URLEncoder.encode(xml.toString(), "UTF8"); System.out.println("Open new connection to tunnel"); HttpURLConnection urlConnection = (HttpURLConnection) server.openConnection(); urlConnection.setRequestMethod( "POST" ); urlConnection.setDoOutput(true); urlConnection.setConnectTimeout(60000); urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); BufferedWriter out = new BufferedWriter( new OutputStreamWriter( urlConnection.getOutputStream() ) ); out.write(sRequest); out.flush(); out.close(); urlConnection.connect(); InputStream is = urlConnection.getInputStream(); String str = urlConnection.getResponseMessage(); System.out.println("Response:"+urlConnection.getResponseCode()); System.out.println("Response:"+urlConnection.getResponseMessage()); StringBuffer strbuf = new StringBuffer(); byte[] buffer = new byte[1024 * 4]; try { int n = 0; while (-1 != (n = is.read(buffer))) { strbuf.append(new String(buffer, 0, n)); } is.close(); } catch (IOException ioe) { ioe.printStackTrace(); } System.out.println(strbuf.toString()); } catch (Exception exp) { exp.printStackTrace(); } return 0; } public static void main (String[] args) { startEncodingWorkflow(); } } Copyright (c) 2009 Encoding.com Inc.
About
Java Script that will send XML requests to encoding.com
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published