library searcher
Unified search API with drivers for Bing and Google
radowoj/searcher
Unified search API with drivers for Bing and Google
- Friday, April 21, 2017
- by radowoj
- Repository
- 0 Watchers
- 0 Stars
- 30 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 5 Versions
- 11 % Grown
searcher
, (*1)
Unified search API for Google, Bing and maybe others in the future. Utilizes Guzzle for http requests., (*2)
Goal
- To use Google / Bing / possibly other Web Search Api with the same interface, regardless of which one is being used under the hood.
Requirements
- PHP >= 7.0
- guzzlehttp/guzzle
Installation
composer require radowoj/searcher
Usage
use GuzzleHttp\Client as GuzzleClient;
use Radowoj\Searcher\SearchProvider\Bing;
use Radowoj\Searcher\SearchProvider\Google;
use Radowoj\Searcher\Searcher;
$client = new GuzzleClient();
//
// If you want to use Google
//
$searchProvider = new Google(
$client,
'your-google-api-key',
'your-custom-search-cx-value-set-in-google-account-panel'
);
//
// Or if you want to use Bing
//
$searchProvider = new Bing(
$client,
'your-bing-api-key'
);
//
// Rest of the necessary code is the same regardless of search provider used
//
$searcher = new Searcher($searchProvider);
$results = $searcher->query('"nyan cat"')
->limit(10)
->offset(0)
->find();
//Array access
var_dump(($results[5])->toArray());
//Traversable
foreach($results as $result){
var_dump($result->toArray());
}
//Countable
var_dump(count($results));
//...and total-result-countable ;)
var_dump($results->totalCount());
dev-master
9999999-dev
Unified search API with drivers for Bing and Google
Sources
Download
MIT
The Requires
The Development Requires
by
Radosław Wojtyczka
v0.4.0
0.4.0.0
Unified search API with drivers for Bing and Google
Sources
Download
MIT
The Requires
The Development Requires
by
Radosław Wojtyczka
v0.3.0
0.3.0.0
Unified search API with drivers for Bing and Google
Sources
Download
MIT
The Requires
The Development Requires
by
Radosław Wojtyczka
v0.2.0
0.2.0.0
Unified search API with drivers for Bing and Google
Sources
Download
MIT
The Requires
The Development Requires
by
Radosław Wojtyczka
v0.1.0
0.1.0.0
Unified search API with drivers for Bing and Google
Sources
Download
MIT
The Requires
The Development Requires
by
radowoj