gabrielbull/sitesearch

This package is abandoned and no longer maintained. No replacement package was suggested.

Google Site Search custom search PHP Wrapper Library

dev-master 2016-07-06 14:38 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:31:04 UTC


README

Build Status

Search engine for websites using Google Custom Search Engine with a Google Site Search account.

Google Site Search API

To use the Google Site Search API, you have to obtain a search engine ID from Google.

Requirements

This library uses PHP 5.3+.

Installation

It is recommended that you install the PHP Google Site Search library through composer.

{
    "require": {
        "gabrielbull/sitesearch": "dev-master"
    }
}

Search

The SiteSearch class allows you to search Google Custom Search Engine. All you have to provide is a search engine ID and a query.

Examples

$id = "YOUR_SEARCH_ENGINE_ID";

$siteSearch = new SiteSearch($id);
$results = $siteSearch->search('kittens');

foreach($results as $result) {
    echo $result['title'];
}

or:

$id = "YOUR_SEARCH_ENGINE_ID";

foreach(SiteSearch::create($id)->search('cats') as $result) {
    echo $result['title'];
}

Parameters

The search method parameters are:

  • value The search query.
  • start The offset of the first result to return.
  • limit The number of results to return.

Results

The search results will contain the following parameters:

  • link The link of the page.
  • title The title of the page.
  • description The description of the page.
  • lang The language of the page.
  • image An image associated with the page (src).
  • thumbnail A thumbnail of the image (src, width and height).