mardi 21 avril 2015

Google Customer Search JSON/XML API

I am trying to use the Google Search API to search for images. However, I got really confused by the Google API documentation.

From here, it mentioned "useful documentation: Google WebSearch Protocol (XML): The JSON/Atom Custom Search API provides a subset of the functionality provided by the XML API, but it instead returns data in JSON or Atom format."

Clearly, they have two different APIs, the XML API and the JSON/ATOM API. I managed to make the JSON/ATOM API work by making requests liek this:

And I can see the response is in JSON format with both the text search and image search. I am thinking about RTFM and customize my search by passing necessary arguments. Then I found the XML API documentation where NOTHING there works.

I tried a few examples there and the XML API gave me 403 errors like below.

Here is the response:

<GSP VER="3.2">
<PARAM js_escaped_value="0" name="start" original_value="0" url_escaped_value="0" value="0"/>
<PARAM js_escaped_value="10" name="num" original_value="10" url_escaped_value="10" value="10"/>
<PARAM js_escaped_value="atmega329" name="q" original_value="atmega329" url_escaped_value="atmega329" value="atmega329"/>
<PARAM js_escaped_value="google-csbe" name="client" original_value="google-csbe" url_escaped_value="google-csbe" value="google-csbe"/>
<PARAM js_escaped_value="xml_no_dtd" name="output" original_value="xml_no_dtd" url_escaped_value="xml_no_dtd" value="xml_no_dtd"/>
<PARAM js_escaped_value="0141916059..." name="cx" original_value="0141916059..." url_escaped_value="0141916059..." value="014191605..."/>
<PARAM js_escaped_value="AIzaSyDy9kSSMnnvOTOep...zDoCvg" name="key" original_value="AIzaSyDy9kSSMnnvOTOepp3..." url_escaped_value="" value="AIzaSyDy9kSSMnnvOTOepp...Cvg"/>

This probably should be a email to Google Customer support. However, Since Google API is so powerful and popular, I decided to give it a try here. Can anyone who has some experience share with me what is really going on with JSON and XML API and where can I find the proper documentation for each of them.

Aucun commentaire:

Enregistrer un commentaire