gplacesphp/api-client
Composer 安装命令:
composer require gplacesphp/api-client
包简介
Modern Google Places API client for PHP
README 文档
README
Build status
| Version | Linux build | Windows build |
|---|---|---|
| v1 (master) |
Introduction
Modern, Object-Oriented, client for using Google's Places API, requires PHP v7.1+. Any PSR-7 (HTTP Message Interface) and PSR-17 (HTTP Factories) implementations is supported (and required). Supports caching by any PSR-16 (simple cache) implementation, also works with any HTTPlug client/adapter.
Installation
composer require gplacesphp/api-client
Usage
This examples uses php-http/guzzle6-adapter as a PSR-18 implementation
and zendframework/zend-diactoros as a PSR-7/PSR-17 implementation.
Any other PSR-7/PSR-17/PSR-18 implementations are supported.
If you don't have them installed you will need to run:
composer require \
guzzlehttp/guzzle \
php-http/guzzle6-adapter \
zendframework/zend-diactoros
Remember to replace <YOUR_API_KEY> with you key.
More usage examples are in examples directory.
Place details
Basic example
<?php require_once __DIR__ . '/vendor/autoload.php'; $apiKey = '<YOUR_API_KEY>'; $guzzle = new \GuzzleHttp\Client(); $httpClient = new \Http\Adapter\Guzzle6\Client($guzzle); $requestFactory = new \Zend\Diactoros\RequestFactory(); $client = \GPlacesPhp\ApiClient\Client::create( $apiKey, $httpClient, $requestFactory ); $placeDetails = $client->placeDetails('ChIJAZ-GmmbMHkcR_NPqiCq-8HI'); // Warsaw var_dump($placeDetails);
Find place
Basic example
<?php require_once __DIR__ . '/vendor/autoload.php'; $apiKey = '<YOUR_API_KEY>'; $guzzle = new \GuzzleHttp\Client(); $httpClient = new \Http\Adapter\Guzzle6\Client($guzzle); $requestFactory = new \Zend\Diactoros\RequestFactory(); $client = \GPlacesPhp\ApiClient\Client::create( $apiKey, $httpClient, $requestFactory ); $findPlace = $client->findPlace('Warszawa, Polska'); // Warsaw var_dump($findPlace);
TODOs
Things to do before stable v1 release:
- Place Details
- Caching Place Details
- Places Search
- Find Place
- Nearby Search
- Text Search
- Caching Places Search
- Find Place
- Nearby Search
- Text Search
- Place Photos
- Caching Place Photos
- Use
PSR-18instead ofHTTPlug
License
This package is free software distributed under the terms of the MIT license.
统计信息
- 总下载量: 2.31k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-16