Search code examples
phpxmlgoogle-custom-search

Google Custom Search Engine (CSE) API


I am trying to integrate a site search feature into a client's site. I've created an test search engine with Google Custom Search, but I can't sort out how to make it work with the following criteria:

  1. The search form posts back to the site
  2. The POST page uses an API to get the result back from Google
  3. I display the results within my site

Am I misunderstanding how Google Custom Search works? Is there a simple tutorial somewhere that fits my criteria?

Thanks!


Solution

  • Google Custom Search Business Edition specifically has the API to return XML results, with which you can do what you please. Business Edition is not free.

    Here is the XML results documentation.

    From PHP, you can use cURL to pass your POSTed search query on to Google CSE as a GET request, and then do whatever you want with the XML server side or client side.