2017 © Pedro Peláez
 

library google-places-sdk-php

Google Places SDK for PHP

image

rodrigobendia/google-places-sdk-php

Google Places SDK for PHP

  • Monday, February 2, 2015
  • by rodrigobendia
  • Repository
  • 1 Watchers
  • 1 Stars
  • 84 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Google Places SDK for PHP

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., (*1)

Installation

Add the following to your composer.json file:, (*2)

{
    "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);
<?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();
}
<?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();
}

The Versions

02/02 2015

dev-master

9999999-dev

Google Places SDK for PHP

  Sources   Download

MIT

The Requires

 

by Rodrigo Bendia

http sdk client guzzle google places