Skip to content

Latest commit

 

History

History
63 lines (42 loc) · 1.39 KB

api_search.md

File metadata and controls

63 lines (42 loc) · 1.39 KB

Search API reference

Retrieving API

<?php

$api = new Places();

$search = $api->getSearchApi();

Available methods

Search by location and radius

<?php

array Search::searchLocation($location, $radius [, array $other = []])

Search by text query

<?php

array Search::textSearch($text [, array $others = []])

Notice: if you specify location, you need to specify also radius

Get an iterator on your search

The parameters of this method are the same as the search method but the result is an iterator that iterate over the Google Places API. It automatically stops when there is no results.

Here is an example of usage:

<?php

$i = $searchApi->getSearchIterator('48.8267545,2.3083555', '100', ['keyword' => 'KFC']);

foreach($i as $key => $data) {
    foreach($data['results'] as $place) {
        if ($place['opening_hours']['open_now'] === true) {
            echo $place['name'] . ' is open right now';
        }
    }
}