Skip to content

stodd/java-v2-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

The Java SDK is a client class for our V2 API. The approach is very simple. 
It allows you to do GET, POST, PUT, PATCH and DELETE requests to our API by simply 
specifying the path to the API you want to hit and depending of the call, a two more 
hashes which depending on the request, they contain the query parameters or the request's body.

To get up and running using the API client, you need to reference the jars on the lib folder on your project:

+ commons-codec-1.4.jar
+ commons-logging-1.1.1.jar
+ httpclient-4.1.2.jar
+ httpclient-cache-4.1.2.jar
+ httpcore-4.1.2.jar
+ httpmime-4.1.2.jar
+ json_simple-1.1.jar

First you need to create an OoyalaAPI object by passing your V2 API keys like this:

    OoyalaAPI api = new OoyalaAPI("<api key>", "<secret key>");
  
Now lets get all the assets under the "Funny dogs" label:

    HashMap<String, String> parameters = new HashMap<String, String>();
    parameters.put("where", "labels INCLUDES 'Funny dogs'");

    LinkedList<HashMap<String,Object>> assets = (LinkedList<HashMap<String,Object>>)api.getRequest("assets", parameters).get("items");
  
Now that we have our results on the assets ArrayList, lets print them out to the console.

    System.out.println("Printing out assets...");
    ListIterator<HashMap<String, Object>> iterator = assets.listIterator();
    while(iterator.hasNext()){
      HashMap<String, Object> asset = iterator.next();
    	System.out.println(asset.get("embed_code").toString() + " - " + asset.get("name").toString());
    }

It's that easy to work with this SDK!

We use json-simple to parse and encode JSON. Please visit http://code.google.com/p/json-simple/ for more information on supported classes when creating your body HashMap.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%