1. Go to this page and download the library: Download skagarwal/google-places-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
skagarwal / google-places-api example snippets
use SKAgarwal\GoogleApi\PlacesNew\GooglePlaces;
public function foo() {
$response = GooglePlaces::make(key: 'API KEY', verifySSL: false, throwOnError: false)->autocomplete('some input');
$data = $response->array();
}
use SKAgarwal\GoogleApi\PlacesNew\GooglePlaces;
public function foo() {
$response = GooglePlaces::make()->autocomplete('some input');
$data = $response->collect();
}
$response->array(); // returns the response as array
$response->collect(); // returns the response as collection
$response->json(); // returns the response as json
$response->status(); // returns the status of the response
$response->headers(); // returns the headers of the response
$response->body(); // returns the body of the response
$response->throw(); // throws an exception if the response is not successful
use SKAgarwal\GoogleApi\Places\GooglePlaces; // Original Places API class
public function foo() {
$response = GooglePlaces::make()->nearbySearch('40.748817,-73.985428');
$data = $response->array();
}
use SKAgarwal\GoogleApi\PlacesNew\GooglePlaces; // New Places API class
public function foo() {
$response = GooglePlaces::make()->nearbySearch(40.748817, -73.985428, 500.0);
$data = $response->array();
}