I am trying to use the Google URL shortener API in my Spring MVC application. I have downloaded the Google API java client zip and added all the jars to my project build path and tried to run a sample code.
// setup up the HTTP transport
HttpTransport transport = GoogleTransport.create();
// add default headers
GoogleHeaders defaultHeaders = new GoogleHeaders();
transport.defaultHeaders = defaultHeaders;
transport.defaultHeaders.put("Content-Type", "application/json");
transport.addParser(new JsonCParser());
// build the HTTP GET request and URL
GenericData data = new GenericData();
data.put("longUrl", "http://www.google.com/");
JsonHttpContent content = new JsonHttpContent();
content.data = data;
HttpRequest request = transport.buildPostRequest();
request.content = content;
request.setUrl(GOOGL_URL);
HttpResponse response;
try {
JSONObject json = request.execute().parseAs(JSONObject.class);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But the problem is it cannot resolve GoogleTransport. I just cant find it in any jar. Can some one please point me to where I can find it. I have no idea whats wrong and constant googling has led me nowhere. And yes, I cannot use maven, downloaded jars are the only option that i have :( . Please any help would be great.