PHP Classes
elePHPant
Icontem

CityGrid API: Search for places using the CityGrid API

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2013-03-25 (3 years ago) RSS 2.0 feedNot enough user ratingsTotal: 244 All time: 7,380 This week: 1,070Up
Version License PHP version Categories
citygrid 1.0GNU General Publi...5.3PHP 5, Web services, Geography
Description Author

This class can search for places using the CityGrid API.

It can send HTTP requests to the CityGrid API Web servers to call any of the Web services functions like searching for places, get place details, search for reviews, search for offers, etc..

The class can decode the JSON response and return the decoded values.

Picture of Egor Gumenuk
Name: Egor Gumenuk is available for providing paid consulting. Contact Egor Gumenuk .
Classes: 3 packages by
Country: Ukraine Ukraine
Age: 23
All time rank: 250043 in Ukraine Ukraine
Week rank: 1350 Up24 in Ukraine Ukraine Up
Innovation award
Innovation award
Nominee: 1x

Details
CityGrid API wrapper for PHP
============================

See [CityGrid API docs](http://docs.citygridmedia.com/display/citygridv2/CityGrid+APIs) for details

Setup
=====

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

```php
<?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](http://docs.citygridmedia.com/display/citygridv2/Places+API#PlacesAPI-SearchUsingWhere)

**Example:** Find movie theaters in zip code 90045

```php
<?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](http://docs.citygridmedia.com/display/citygridv2/Places+API#PlacesAPI-SearchUsingLatitudeandLongitude)

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

```php
<?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](http://docs.citygridmedia.com/display/citygridv2/Places+API#PlacesAPI-PlacesDetail)

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

```php
<?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](http://docs.citygridmedia.com/display/citygridv2/Offers+API#OffersAPI-SearchUsingWhere)

**Example:** Find offers for Sushi restaurants in Los Angeles

```php
<?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](http://docs.citygridmedia.com/display/citygridv2/Offers+API#OffersAPI-SearchUsingLatitudeandLongitude)

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

```php
<?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](http://docs.citygridmedia.com/display/citygridv2/Offers+API#OffersAPI-OffersDetail)

**Example:** Look up Offer with id cg_64232690

```php
<?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](http://docs.citygridmedia.com/display/citygridv2/Reviews+API#ReviewsAPI-ReviewsSearch)

**Example:** Find reviews for sushi restaurants in Los Angeles

```php
<?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](http://docs.citygridmedia.com/display/citygridv2/Reviews+API#ReviewsAPI-SearchUsingLatitudeandLongitude)

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

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

$result = $cg->reviewsLatLon($options);
```
  Files folder image Files  
File Role Description
Plain text file CityGrid.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:244
This week:0
All time:7,380
This week:1,070Up