rodrigobendia/google-places-sdk-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rodrigobendia/google-places-sdk-php

Composer 安装命令:

composer require rodrigobendia/google-places-sdk-php

包简介

Google Places SDK for PHP

README 文档

README

The Google Places SDK for PHP enables developers to use the Google Places API in their PHP code. This library is based on Guzzle HTTP Client.

Installation

Add the following to your composer.json file:

{
    "require": {
      "rodrigobendia/google-places-sdk-php": "dev-master"
    }
}

Usage

Initialization

<?php

use Bendia\API\Clients\GooglePlacesApiClient;

$apiKey = 'YOUR_API_KEY';

// Initialize the instance with yout API key
GooglePlacesApiClient::instance($apiKey);

Places Search

<?php

use Bendia\API\Clients\GooglePlacesApiClient;
use Bendia\API\Clients\GooglePlacesSearchResponse;

$location = [37.424307, -122.09502299999997];
$radius = 1000;
$sensor = false;

// Assuming that the singleton has been initialized with the API key before
$response = GooglePlacesApiClient::instance()->search($location, $radius, $sensor);

// Check response status
if ($response->isOk())
{
    for ($i = 0; $i < $response->countResults(); $i++)
    {
        $place = $response->getResult($index);
        
        echo $place->name;
        echo $place->formatted_address;
    }
}
else
{
    echo $response->getStatus();
}

Text Search

<?php

use Bendia\API\Clients\GooglePlacesApiClient;
use Bendia\API\Clients\GooglePlacesSearchResponse;

$query = 'Google Mountain View';
$sensor = false;

// Assuming that the singleton has been initialized with the API key before
$response = GooglePlacesApiClient::instance()->searchText($query, $sensor);

// Check response status
if ($response->isOk())
{
    for ($i = 0; $i < $response->countResults(); $i++)
    {
        $place = $response->getResult($index);
        
        echo $place->name;
        echo $place->formatted_address;
    }
}
else
{
    echo $response->getStatus();
}

Place Details

<?php

use Bendia\API\Clients\GooglePlacesApiClient;
use Bendia\API\Clients\GooglePlacesDetailsResponse;

$placeId = 'ChIJYVBMERu6j4ARH8TCQcqmK6M';
$reference = null;
$sensor = false;

// Assuming that the singleton has been initialized with the API key before
$response = GooglePlacesApiClient::instance()->getDetails($placeId, $reference, $sensor);

// Check response status
if ($response->isOk())
{
    $place = $response->getResult();

    echo $place->name;
    echo $place->formatted_address;
}
else
{
    echo $response->getStatus();
}

统计信息

  • 总下载量: 113
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固