gabrielbull / sitesearch
Google Site Search custom search PHP Wrapper Library
Installs: 35
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/gabrielbull/sitesearch
This package is not auto-updated.
Last update: 2022-02-01 12:31:04 UTC
README
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:
valueThe search query.startThe offset of the first result to return.limitThe number of results to return.
Results
The search results will contain the following parameters:
linkThe link of the page.titleThe title of the page.descriptionThe description of the page.langThe language of the page.imageAn image associated with the page (src).thumbnailA thumbnail of the image (src, width and height).