Getting Started
Download location: vmsrpc.jar
There are extra jar files needed for the json parse example to work:
javax.json-api-1.0.jar
javax.json-1.0.3.jar
Make sure the jar files are in a location that's included in the classpath of the project.
Import these classes:
import java.io.*;
import java.util.*;
import javax.json.*;
import javax.json.stream.*;
import com.bluebillywig.VmsRpc;
Create a new instance of vmsrpc:
VmsRpc vmsRpc = new VmsRpc("http://<publication>.bbvms.com","<username>","<password>");
The following example demonstrates how to search for a couple of mediaclips and immediately print the embed code for each mediaclip:
Map<String,String> properties = new HashMap<String,String>();
properties.put("query","type:mediaclip AND status:published");
properties.put("limit","10");
properties.put("sort","createddate desc");
String json = vmsRpc.json( "search", null, properties );
byte[] bytes = json.getBytes();
InputStream inputStream = new ByteArrayInputStream(bytes);
JsonParser parser = Json.createParser( inputStream );
boolean idFound = false;
while (parser.hasNext()) {
JsonParser.Event event = parser.next();
switch(event) {
case KEY_NAME:
if( parser.getString().equals("id") ){
idFound = true;
}
break;
case VALUE_STRING:
case VALUE_NUMBER:
if( idFound ){
String embedCode = "<script type=\"text/javascript\" src=\"http://publication.bbvms.com/p/default/c/" + parser.getString() + ".js\"></script>";
System.out.println( embedCode );
}
idFound = false;
break;
case START_ARRAY:
case END_ARRAY:
case START_OBJECT:
case END_OBJECT:
case VALUE_FALSE:
case VALUE_NULL:
case VALUE_TRUE:
}
}