Mohammad S Anwar > WWW-Google-Places > WWW::Google::Places

Download:
WWW-Google-Places-0.22.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.22   Source  

NAME ^

WWW::Google::Places - Interface to Google Places API.

VERSION ^

Version 0.22

DESCRIPTION ^

The Google Places API is a service that returns information about Places, defined within this API as establishments, geographic location or prominent points of interest using HTTP request.Place requests specify location as latitude/longitude coordinates. Users with an API key are allowed 1,000 requests per 24 hour period. Currently it supports version v3.

SYNOPSIS ^

    use strict; use warnings;
    use WWW::Google::Places;

    my $api_key = 'YOUR_API_KEY';
    my $place   = WWW::Google::Places->new({ api_key => $api_key });

    # Google search place
    my @results = $place->search({ location => '-33.8670522,151.1957362', radius => 500 });
    foreach (@results) {
        print "Id      : ", $_->place_id,             "\n";
        print "Name    : ", $_->name,                 "\n";
        print "Types   : ", join(", ", @{$_->types}), "\n";
        print "Geometry: ", $_->geometry,             "\n";
        print "Icon    : ", $_->icon,                 "\n";
        print "Vicinity: ", $_->vicinity,             "\n";
        print "Scope   : ", $_->scope,                "\n";
        print "----------------------------------------\n";
    }

    # Google search place details
    my $place_id = 'ChIJ1ZL9NkGuEmsRUEkzFmh9AQU';
    my $result   = $place->details($place_id);
    print "Name              : ", $result->name,                   "\n";
    print "Types             : ", join(", ", @{$result->types}),   "\n";
    print "URL               : ", $result->url,                    "\n";
    print "Vicinity          : ", $result->vicinity,               "\n";
    print "Website           : ", $result->website,                "\n";
    print "Phone Number      : ", $result->formatted_phone_number, "\n";
    print "Address           : ", $result->formatted_address,      "\n";
    print "Reference         : ", $result->reference,              "\n";
    print "UTF Offset        : ", $result->utf_offset,             "\n";
    print "Scope             : ", $result->scope,                  "\n";
    print "Icon              : ", $result->icon,                   "\n";
    print "Reviews           : ", join("| ", @{$result->reviews}), "\n";
    print "Rating            : ", $result->rating,                 "\n";
    print "User Ratings      : ", $result->user_ratings_total,     "\n";
    print "Opening Hours     : ", $result->opening_hours,          "\n";
    print "Internation Number: ", $result->internation_number,     "\n";
    print "Photos            : ", $result->photos,                 "\n";

PLACE TYPES ^

Supported types for Place adds/searches.

    +---------------------------------+
    | accounting                      |
    | airport                         |
    | amusement_park                  |
    | aquarium                        |
    | art_gallery                     |
    | atm                             |
    | bakery                          |
    | bank                            |
    | bar                             |
    | beauty_salon                    |
    | bicycle_store                   |
    | book_store                      |
    | bowling_alley                   |
    | bus_station                     |
    | cafe                            |
    | campground                      |
    | car_dealer                      |
    | car_rental                      |
    | car_repair                      |
    | car_wash                        |
    | casino                          |
    | cemetery                        |
    | church                          |
    | city_hall                       |
    | clothing_store                  |
    | convenience_store               |
    | courthouse                      |
    | dentist                         |
    | department_store                |
    | doctor                          |
    | electrician                     |
    | electronics_store               |
    | embassy                         |
    | establishment                   |
    | finance                         |
    | fire_station                    |
    | florist                         |
    | food                            |
    | funeral_home                    |
    | furniture_store                 |
    | gas_station                     |
    | general_contractor              |
    | geocode                         |
    | grocery_or_supermarket          |
    | gym                             |
    | hair_care                       |
    | hardware_store                  |
    | health                          |
    | hindu_temple                    |
    | home_goods_store                |
    | hospital                        |
    | insurance_agency                |
    | jewelry_store                   |
    | laundry                         |
    | lawyer                          |
    | library                         |
    | liquor_store                    |
    | local_government_office         |
    | locksmith                       |
    | lodging                         |
    | meal_delivery                   |
    | meal_takeaway                   |
    | mosque                          |
    | movie_rental                    |
    | movie_theater                   |
    | moving_company                  |
    | museum                          |
    | night_club                      |
    | painter                         |
    | park                            |
    | parking                         |
    | pet_store                       |
    | pharmacy                        |
    | physiotherapist                 |
    | place_of_worship                |
    | plumber                         |
    | police                          |
    | post_office                     |
    | real_estate_agency              |
    | restaurant                      |
    | roofing_contractor              |
    | rv_park                         |
    | school                          |
    | shoe_store                      |
    | shopping_mall                   |
    | spa                             |
    | stadium                         |
    | storage                         |
    | store                           |
    | subway_station                  |
    | synagogue                       |
    | taxi_stand                      |
    | train_station                   |
    | travel_agency                   |
    | university                      |
    | veterinary_care                 |
    | zoo                             |
    +---------------------------------+

Additional types listed below can be used in Place Searches, but not when adding a Place.

    +---------------------------------+
    | administrative_area_level_1     |
    | administrative_area_level_2     |
    | administrative_area_level_3     |
    | colloquial_area                 |
    | country                         |
    | floor                           |
    | intersection                    |
    | locality                        |
    | natural_feature                 |
    | neighborhood                    |
    | political                       |
    | point_of_interest               |
    | post_box                        |
    | postal_code                     |
    | postal_code_prefix              |
    | postal_town                     |
    | premise                         |
    | room                            |
    | route                           |
    | street_address                  |
    | street_number                   |
    | sublocality                     |
    | sublocality_level_4             |
    | sublocality_level_5             |
    | sublocality_level_3             |
    | sublocality_level_2             |
    | sublocality_level_1             |
    | subpremise                      |
    | transit_station                 |
    +---------------------------------+

LANGUAGES ^

    +-------+-------------------------+
    | Code  | Name                    |
    +-------+-------------------------+
    | ar    | ARABIC                  |
    | eu    | BASQUE                  |
    | bg    | BULGARIAN               |
    | bn    | BENGALI                 |
    | ca    | CATALAN                 |
    | cs    | CZECH                   |
    | da    | DANISH                  |
    | de    | GERMAN                  |
    | el    | GREEK                   |
    | en    | ENGLISH                 |
    | en-AU | ENGLISH (AUSTRALIAN)    |
    | en-GB | ENGLISH (GREAT BRITAIN) |
    | es    | SPANISH                 |
    | eu    | BASQUE                  |
    | fa    | FARSI                   |
    | fi    | FINNISH                 |
    | fil   | FILIPINO                |
    | fr    | FRENCH                  |
    | gl    | GALICIAN                |
    | gu    | GUJARATI                |
    | hi    | HINDI                   |
    | hr    | CROATIAN                |
    | hu    | HUNGARIAN               |
    | id    | INDONESIAN              |
    | it    | ITALIAN                 |
    | iw    | HEBREW                  |
    | ja    | JAPANESE                |
    | kn    | KANNADA                 |
    | ko    | KOREAN                  |
    | lt    | LITHUANIAN              |
    | lv    | LATVIAN                 |
    | ml    | MALAYALAM               |
    | mr    | MARATHI                 |
    | nl    | DUTCH                   |
    | no    | NORWEGIAN               |
    | pl    | POLISH                  |
    | pt    | PORTUGUESE              |
    | pt-BR | PORTUGUESE (BRAZIL)     |
    | pt-PT | PORTUGUESE (PORTUGAL)   |
    | ro    | ROMANIAN                |
    | ru    | RUSSIAN                 |
    | sk    | SLOVAK                  |
    | sl    | SLOVENIAN               |
    | sr    | SERBIAN                 |
    | sv    | SWEDISH                 |
    | tl    | TAGALOG                 |
    | ta    | TAMIL                   |
    | te    | TELUGU                  |
    | th    | THAI                    |
    | tr    | TURKISH                 |
    | uk    | UKRAINIAN               |
    | vi    | VIETNAMESE              |
    | zh-CN | CHINESE (SIMPLIFIED)    |
    | zh-TW | CHINESE (TRADITIONAL)   |
    +-------+-------------------------+

CONSTRUCTOR ^

The constructor expects the following keys. Only the 'api_key' is mandatory and others are optionals.

    +-----------+---------------------------------------------------------------+
    | Parameter | Description                                                   |
    +-----------+---------------------------------------------------------------+
    | api_key   | Your application API key. You should supply a valid API key   |
    |           | with all requests. Get a key from the Google APIs console.    |
    |           | This must be provided.                                        |
    | sensor    | Indicates whether or not the Place request came from a device |
    |           | using a location sensor (e.g. a GPS) to determine the location|
    |           | sent in this request. This value must be either true or false.|
    |           | Default is false.                                             |
    | language  | The language code, indicating in which language the results   |
    |           | should be returned. The default is en.                        |
    +-----------+---------------------------------------------------------------+

    use strict; use warnings;
    use WWW::Google::Places;

    my $api_key = 'Your_API_Key';
    my $place   = WWW::Google::Places->new({ api_key => $api_key });

METHODS ^

search(\%params)

It expects a ref to hash as the only parameter containing the following keys. It returns list of objects of type WWW::Google::Places::SearchResult in a LIST context and ref to the same list in a SCALAR context.

    +----------+----------------------------------------------------------------+
    | Key      | Description                                                    |
    +----------+----------------------------------------------------------------+
    | location | The latitude/longitude around which to retrieve Place          |
    |          | information. This must be provided as a google.maps.LatLng     |
    |          | object. This must be provided.                                 |
    | radius   | The distance (in meters) within which to return Place results. |
    |          | The recommended best practice is to set radius based on the    |
    |          | accuracy of the location signal as given by the location       |
    |          | sensor. Note that setting a radius biases result to the        |
    |          | indicated area, but may not fully restrict results to the      |
    |          | specified area. This must be provided.                         |
    | types    | Restricts the results to Places matching at least one of the   |
    |          | specified types. Types should be separated with a pipe symbol. |
    | name     | A term to be matched against the names of Places.              |
    +----------+----------------------------------------------------------------+

    use strict; use warnings;
    use WWW::Google::Places;

    my $api_key = 'Your_API_Key';
    my $place   = WWW::Google::Places->new({ api_key => $api_key });
    my $results = $place->search({ location=>'-33.8670522,151.1957362', radius=>500 });

paged_search(\%params)

Accepts the same values as search(\%params) but handles queries that have multiple pages worth of data. Using paged_search the max number of results is 60 (or 3 pages worth) https://developers.google.com/places/documentation/search#PlaceSearchRequests

It returns list of objects of type WWW::Google::Places::SearchResult in a LIST context and ref to a list in a SCALAR context.

NOTE:Due to the way that Google handles the paging of results there is a required sleep of 2 seconds between each requests so that the Google pageTokens can become active.

    use strict; use warnings;
    use WWW::Google::Places;

    my $api_key = 'Your_API_Key';
    my $place   = WWW::Google::Places->new({ api_key => $api_key });
    my $results = $place->paged_search(
                  { location => '34.0522222,-118.2427778',
                    radius   => 500,
                    types    => 'bar|restaurant',
                  });

details($place_id)

Expects place id, a textual identifier that uniquely identifies a place, returned from a Place Search. It then returns an object of type WWW::Google::Places::DetailResult.

    use strict; use warnings;
    use WWW::Google::Places;

    my $api_key = 'Your_API_Key';
    my $placeid = 'Place_ID';
    my $place   = WWW::Google::Places->new({ api_key => $api_key });
    my $details = $place->details($placeid);

add(\%params)

Expects a ref to hash as the only parameter containing the following keys.It then returns place id.

    +----------+----------------------------------------------------------------+
    | Key      | Description                                                    |
    +----------+----------------------------------------------------------------+
    | location | The latitude/longitude around which to retrieve Place          |
    |          | information. This must be provided as a google.maps.LatLng     |
    |          | object.                                                        |
    | accuracy | The accuracy of the location signal on which this request is   |
    |          | based, expressed in meters. This must be provided.             |
    | name     | The full text name of the Place.                               |
    | types    | Restricts the results to Places matching at least one of the   |
    |          | specified types. Types should be separated with a pipe symbol. |
    +----------+----------------------------------------------------------------+

    use strict; use warnings;
    use WWW::Google::Places;

    my $api_key = 'Your_API_Key';
    my $place   = WWW::Google::Places->new({ api_key => $api_key });
    my $status  = $place->add({ 'location'=>'-33.8669710,151.1958750', accuracy=>40, name=>'Google Shoes!' });

delete($place_id)

Expects place id, a textual identifier that uniquely identifies a place, returned from a Place Search.

Delete a place as given reference. Place can be deleted by the same application that has added it in the first place.Once moderated and added into the full Place Search results, a Place can no longer be deleted. Places that are not accepted by the moderation process will continue to be visible to the application that submitted them.

    use strict; use warnings;
    use WWW::Google::Places;

    my $api_key  = 'Your_API_Key';
    my $place_id = 'Place_ID';
    my $place    = WWW::Google::Places->new({ api_key => $api_key });
    my $status   = $place->delete($place_id);

search_place(%params) *** DEPRECATED ***

Instead call method search().

Returns a list of objects of type WWW::Google::Places::SearchResult.

place_detail($reference) *** DEPRECATED ***

Instead call method details().

Returns an object of type WWW::Google::Places::DetailResult.

add_place(%params) *** DEPRECATED ***

Instead call method add().

Returns an object of type WWW::Google::Places::DetailResult.

delete_place($reference) *** DEPRECATED ***

Instead call method delete().

place_checkins() *** UNSUPPORTED ***

AUTHOR ^

Mohammad S Anwar, <mohammad.anwar at yahoo.com>

REPOSITORY ^

https://github.com/Manwar/WWW-Google-Places

CONTRIBUTORS ^

BUGS ^

Please report any bugs or feature requests to bug-www-google-places at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Google-Places. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc WWW::Google::Places

You can also look for information at:

LICENSE AND COPYRIGHT ^

Copyright (C) 2011 - 2015 Mohammad S Anwar.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License.By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you,you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement,then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax highlighting: