Wrapper for CityGrid API
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
CityGrid.php
README.md

README.md

CityGrid API wrapper for PHP

See CityGrid API docs for details

Setup

To get access to CityGrid api you need to instantiate api driver with your publisher code.

<?php
require 'CityGrid.php';
$publisher = 'test'; // Your publisher code goes here
$cg = new CityGrid($publisher);

Now $cg object could be used for api calls.

Places Search

The Places Search API provides programmatic access to CityGrid's local search engine, delivering basic place details together with metadata allowing subsequent refinement and expansion searches.

Search For Places Using Where

The where endpoint returns places whose geography is specified with free-form text. The text can consist of a zip code, the name of a neighborhood or city, or a street address.

Query params and response data reference

Example: Find movie theaters in zip code 90045

<?php
$options = array(
    'type'  => 'movietheater',
    'where' => '90045'
);

$result = $cg->search($options);

Search For Places Using Latitude and Longitude

The latlon endpoint allows you to search for places using a geographic region defined by latitude and longitude.

Query params and response data reference

Example: Find movie theaters within 5 miles of latitude 34.03N, longitude118.28W

<?php
$options = array(
    'type'   => 'movietheater',
    'lat'    => '34.03',
    'lon'    => '-118.28',
    'radius' => '5'
);

$result = $cg->searchLatLon($options);

Places Detail

The Places Details API provides programmatic access to CityGrid's local listings data, including businesses and events.

Query params and response data reference

Example: Find the place with listing id 10100230, placement "search_page", and client ip 127.0.0.1 (default)

<?php
$options = array(
    'id'        => '10100230',
    'id_type'   => 'cs',
    'placement' => 'search_page'
);

$result = $cg->detail($options);

Offers Search

The Offers Search API provides programmatic access to CityGrid's local search engine, delivering offers, deals, and coupons together with metadata including URIs for subsequent refinement and expansion searches.

Search For Offers Using Where

The where endpoint allows you to search for offers using a place name or zip code. It is useful for free-form text and broad geographical region-based searches.

Query params and response data reference

Example: Find offers for Sushi restaurants in Los Angeles

<?php
$options = array(
    'what'  => 'sushi',
    'where' => 'los angeles,ca'
);

$result = $cg->offers($options);

Search For Offers Using Latitude and Longitude

The latlon endpoint allows you to search for offers using a geographic region defined by latitude and longitude.

Query params and response data reference

Example: Find offers for sushi in latitude 34.03N, longitude118.28W

<?php
$options = array(
    'what'   => 'sushi',
    'lat'    => '34.03',
    'lon'    => '-118.28',
    'radius' => '5'
);

$result = $cg->offersLatLon($options);

Offers Detail

The Offers Detail API provides programmatic access to CityGrid's local search engine, delivering offers, deals, and coupons for specific listings.

Query params and response data reference

Example: Look up Offer with id cg_64232690

<?php
$options = array(
    'id' => 'cg_64232690'
);

$result = $cg->offersDetail($options);

Reviews Search

The Reviews Search API provides programmatic access to CityGrid's reviews database.

Search For Reviews Using Where

The where endpoint returns places whose geography is specified with free-form text. The text can consist of a zip code, the name of a neighborhood or city, or a street address.

Query params and response data reference

Example: Find reviews for sushi restaurants in Los Angeles

<?php
$options = array(
    'where' => 'los angeles,ca',
    'what'  => 'sushi'
);

$result = $cg->reviews($options);

Search For Reviews Using Latitude and Longitude

The latlon endpoint allows you to search for places using a geographic region defined by latitude and longitude.

Query params and response data reference

Example: Find reviews for sushi restaurants around Lat=34.10652 & Lon=-118.411509

<?php
$options = array(
    'lat'    => '34.10652',
    'lon'    => '-118.411509',
    'radius' => '10',
    'what'   => 'sushi'
);

$result = $cg->reviewsLatLon($options);