Mohammad S Anwar > WWW-SearchWikipedia-0.02 > WWW::SearchWikipedia

Download:
WWW-SearchWikipedia-0.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.02   Source  

NAME ^

WWW::SearchWikipedia - Interface to Search Wikipedia API.

VERSION ^

Version 0.02

DESCRIPTION ^

A very lightweight wrapper for the Search Wikipedia REST API provided by wikilocation.org.

CONSTRUCTOR ^

    +--------+----------+--------------------------------------------------------------------+
    | Key    | Required | Description                                                        |
    +--------+----------+--------------------------------------------------------------------+
    | locale |    No    | Use this parameter in order to search for article from a different | 
    |        |          | wikipedia.org locale. Default is 'en'.                             | 
    | format |    No    | The desired output format, either 'json' / 'xml'. Default is json. |
    | debug  |    No    | If set to true then it will suppress the application/x-json header |
    |        |          | on any returned json stream. Default is false.                     |
    +--------+----------+--------------------------------------------------------------------+

    use strict; use warnings;
    use WWW::SearchWikipedia;
    
    my ($search);
    
    $search = WWW::SearchWikipedia->new();
    # or
    $search = WWW::SearchWikipedia->new(locale => 'en', format => 'xml', debug => 'true');
    # or
    $search = WWW::SearchWikipedia->new(locale => 'en');
    # or
    $search = WWW::SearchWikipedia->new({locale => 'en', format => 'xml', debug => 'true'});
    # or
    $search = WWW::SearchWikipedia->new({locale => 'en'});

LOCALES ^

Supported locales listed here with articles count:

    +---------------------+
    | Locale | Articles   |
    +--------+------------+
    |   ar   | 6,478      |
    |   bg   | 18,281     |
    |   ca   | 130,711    |
    |   cs   | 7          |
    |   da   | 54,053     |
    |   de   | 354,629    |
    |   en   | 1,116,511  |
    |   eo   | 46,399     |
    |   es   | 197,825    |
    |   fa   | 18,845     |
    |   fi   | 16,865     |
    |   fr   | 299,472    |
    |   he   | 1          |
    |   hu   | 26,403     |
    |   id   | 17,003     |
    |   it   | 152,168    |
    |   ja   | 64,246     |
    |   ko   | 8,691      |
    |   lt   | 33,706     |
    |   ms   | 24,877     |
    |   nl   | 456,858    |
    |   no   | 44,028     |
    |   pl   | 173,171    |
    |   pt   | 142,149    |
    |   ro   | 23,603     |
    |   ru   | 196,198    |
    |   sk   | 5,664      |
    |   sl   | 9,825      |
    |   sr   | 53,245     |
    |   sv   | 33,738     |
    |   tr   | 9,867      |
    |   uk   | 103,305    |
    |   vi   | 72,188     |
    |   vo   | 94,470     |
    |   war  | 99         |
    |   zh   | 20,412     |
    +--------+------------+

METHODS ^

article()

Find nearby Wikipedia articles based on a specific latitude and longitude.

    +--------+----------+--------------------------------------------------------------------+
    | Key    | Required | Description                                                        | 
    +--------+----------+--------------------------------------------------------------------+
    | lat    |    Yes   | Latitude in decimal degree format.                                 |
    | lng    |    Yes   | Longitude in decimal degree format.                                |
    | radius |    No    | The radius (in metres) to search within. There is a maximum radius | 
    |        |          | of 20km and it will default to 250m if no radius is supplied.      |
    | limit  |    No    | The number of results you want to return. There is a maximum limit | 
    |        |          | of 50 results although you can paginate. This will default to 50   |
    |        |          | if no lower figure is sent.                                        |
    | offset |    No    | The offset from the first result returned. There is no maximum for |
    |        |          | this parameter. The default is 0.                                  | 
    | type   |    No    | The type of article you are interested in.There are various options| 
    |        |          | for this so best to look at some results and then filter from there| 
    |        |          | (you could filter by a type of "river" or "landmark"). The default |
    |        |          | is no filter.                                                      |
    +--------+----------+--------------------------------------------------------------------+

    use strict; use warnings;
    use WWW::SearchWikipedia;
    
    my $search = WWW::SearchWikipedia->new();
    print $search->article({lat => 51.500688, lng => -0.124411, limit => 1}) . "\n";

gowalla()

Find Wikipedia articles based on a Gowalla spot ID. The spot ID can be found by going to the spot on the Gowalla website ( e.g. http://gowalla.com/spots/22087 ) and then taking the digits from the end of the URL (in this case "22087"). This method will return not only an "articles" array (which lists the Wikipedia entries along with their distance from the Gowalla spot) but also a "spot" array giving some basic details from Gowalla such as lat/lng, name, and the radius.

    +-------+----------+---------------------------------------------------------------------+
    | Key   | Required | Description                                                         | 
    +-------+----------+---------------------------------------------------------------------+
    | id    |   Yes    | The Gowalla spot ID.                                                |
    | exact |   No     | Defaults to false. If set to true it will only return articles with | 
    |       |          | the exact same name as the Gowalla spot.                            | 
    +-------+----------+---------------------------------------------------------------------+

    use strict; use warnings;
    use WWW::SearchWikipedia;
    
    my $search = WWW::SearchWikipedia->new();
    print $search->gowalla(id => 22087) . "\n";

foursquare()

Find Wikipedia articles based on a Foursquare venue ID. The venue ID can be found by going to the spot on the Foursquare website ( e.g. http://foursquare.com/venue/141395 ) and then taking the digits from the end of the URL (in this case "141395"). This method will return not only an "articles" array ( which lists the Wikipedia entries along with their distance from the Foursquare venue ) but also a "venue" array giving some basic details from Foursquare such as lat/lng and name.The radius will be either the default of 250m or the radius you defined as a parameter.

    +--------+----------+--------------------------------------------------------------------+
    | Key    | Required | Description                                                        |
    +--------+----------+--------------------------------------------------------------------+
    | id     |   Yes    | The Foursquare venue ID.                                           |
    | radius |   No     | The radius (in metres) to search within. There is a maximum radius |
    |        |          | of 5km and it will default to 250m if no radius is supplied.       |
    | exact  |   No     | Defaults to false. If set to true it will only return articles with|
    |        |          | the exact same name as the Foursquare venue.                       |
    +--------+----------+--------------------------------------------------------------------+

    use strict; use warnings;
    use WWW::SearchWikipedia;
    
    my $search = WWW::SearchWikipedia->new();
    print $search->foursquare(id => 141395) . "\n";

woeid()

Find Wikipedia articles based on a Yahoo! WOEID.A WOEID is a unique, non-repetitive identifier for any geolocational object from a famous landmark to a continent. This method will return not only an "articles" array ( which lists the Wikipedia entries along with their distance from the "centroid" ) but also a "woeid" array giving some basic details from Yahoo! such as lat/lng & name.The radius will be either the default of 250m or the radius you defined as a parameter.

    +--------+----------+--------------------------------------------------------------------+
    | Key    | Required | Description                                                        |
    +--------+----------+--------------------------------------------------------------------+
    | id     |   Yes    | The Yahoo! WOEID.                                                  |
    | radius |   No     | The radius (in metres) to search within. There is a maximum radius |
    |        |          | of 5km and it will default to 250m if no radius is supplied.       |
    | exact  |   No     | Defaults to false. If set to true it will only return articles with|
    |        |          | the exact same name as the WOEID name.                             |
    +--------+----------+--------------------------------------------------------------------+

    use strict; use warnings;
    use WWW::SearchWikipedia;
    
    my $search = WWW::SearchWikipedia->new();
    print $search->woeid(id => 22474116) . "\n";

AUTHOR ^

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

BUGS ^

Please report any bugs or feature requests to bug-www-searchwikipedia at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-SearchWikipedia. 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::SearchWikipedia

You can also look for information at:

ACKNOWLEDGEMENT ^

Ben Dodson (author of WikiLocation REST API).

LICENSE AND COPYRIGHT ^

Copyright 2011 Mohammad S Anwar.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

DISCLAIMER ^

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

syntax highlighting: