Using JSON with Java - Searching web images from stand alone app

50 views
Skip to first unread message

Pedro Guillermo Feijóo García

unread,
Jul 28, 2014, 11:45:50 PM7/28/14
to google-ajax...@googlegroups.com
Greetings,

For acadmic purposes, I want to create a standalone app which can search and find web images with word keys.

Code:

URL url = new URL("https://ajax.googleapis.com/ajax/services/search/images?" +
                  
"v=1.0&q=barack%20obama&userip=INSERT-USER-IP");
URLConnection connection = url.openConnection();
connection
.addRequestProperty("Referer", /* Enter the URL of your site here */);

String line;
StringBuilder builder = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while((line = reader.readLine()) != null) {
 builder
.append(line);
}

JSONObject json = new JSONObject(builder.toString());
I have the following questions, in base of this code:
1) Which library (jar file) should I use of JSON? (The page recomended in the Google example doesn't show libraries or jars)
2) If I'm writing a standalone application, what should I put in the /*Enter the URL of your site here*/ thing?

Thank you a lot :)

Jeremy Geerdes

unread,
Jul 30, 2014, 4:36:10 PM7/30/14
to google-ajax...@googlegroups.com
In the case of a standalone application's HTTP Referer header it is strongly recommended that you create a static webpage with information about your app, including your contact information, so that Google may contact you if it should have need. You would then include the URL of that page as the HTTP Referer.

As for the jar files issue, I'm not a Java dev, so I'll let someone else speak into that matter.

jg





--
--
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
google-ajax...@googlegroups.com
To unsubscribe from this group, send email to
google-ajax-searc...@googlegroups.com
To view this message on the web, visit
https://groups.google.com/d/msgid/google-ajax-search-api/9a1bb579-ca73-4cb4-bb06-b72f10631cf7%40googlegroups.com
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-ajax-searc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jeremy R. Geerdes
Generally Cool Guy
Des Moines, IA

If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church!
Reply all
Reply to author
Forward
0 new messages