cvs: peardoc /en/package webservices-entities.xml /en/package/webservices services-geonames.xml /en/package/webservices/services-geonames
examples.xml getting-started.xml intro.xml /entities global.ent

From: Date: Fri, 19 Dec 2008 17:30:45 +0000
Subject: cvs: peardoc /en/package webservices-entities.xml /en/package/webservices services-geonames.xml /en/package/webservices/services-geonames
examples.xml getting-started.xml intro.xml /entities global.ent
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-11322@lists.php.net to get a copy of this message
izi Fri Dec 19 17:30:45 2008 UTC Added files: /peardoc/en/package/webservices services-geonames.xml /peardoc/en/package/webservices/services-geonames examples.xml getting-started.xml intro.xml Modified files: /peardoc/en/package webservices-entities.xml /peardoc/entities global.ent Log: added services-geonames documentation

http://cvs.php.net/viewvc.cgi/peardoc/en/package/webservices-entities.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/webservices-entities.xml diff -u peardoc/en/package/webservices-entities.xml:1.2 peardoc/en/package/webservices-entities.xml:1.3 --- peardoc/en/package/webservices-entities.xml:1.2 Tue Dec 16 17:22:06 2008 +++ peardoc/en/package/webservices-entities.xml Fri Dec 19 17:30:44 2008 @@ -2,6 +2,7 @@ &package.webservices.services-blogging; &package.webservices.services-delicious; &package.webservices.services-ebay; +&package.webservices.services-geonames; &package.webservices.services-google; &package.webservices.services-technorati; &package.webservices.services-w3c-htmlvalidator; http://cvs.php.net/viewvc.cgi/peardoc/entities/global.ent?r1=1.6&r2=1.7&diff_format=u Index: peardoc/entities/global.ent diff -u peardoc/entities/global.ent:1.6 peardoc/entities/global.ent:1.7 --- peardoc/entities/global.ent:1.6 Mon Nov 17 21:06:07 2008 +++ peardoc/entities/global.ent Fri Dec 19 17:30:45 2008 @@ -1,6 +1,6 @@ <!-- -*- SGML -*- - $Id: global.ent,v 1.6 2008/11/17 21:06:07 cweiske Exp $ + $Id: global.ent,v 1.7 2008/12/19 17:30:45 izi Exp $ Contains global "macros" for all the XML documents. @@ -36,6 +36,8 @@ <!ENTITY url.faq.licenses.rasmus 'http://news.php.net/php.pear.dev/45245'> <!ENTITY url.faq.licenses.apache1 'http://www.apache.org/licenses/LICENSE-1.1'> <!ENTITY url.faq.licenses.fsf 'http://www.fsf.org/licensing/licenses/gpl-faq.html#MereAggregation'> +<!ENTITY url.geonames.home 'http://www.geonames.org/'> +<!ENTITY url.geonames.apidocs 'http://www.geonames.org/export/ws-overview.html'> <!ENTITY url.google.code 'http://code.google.com/'> <!ENTITY url.google.soapsearch 'http://code.google.com/apis/soapsearch/'> <!ENTITY url.gtk2-filedrop.urilist 'http://gtk.php.net/manual1/en/tutorials.filednd.urilist.php'> http://cvs.php.net/viewvc.cgi/peardoc/en/package/webservices/services-geonames.xml?view=markup&rev=1.1 Index: peardoc/en/package/webservices/services-geonames.xml +++ peardoc/en/package/webservices/services-geonames.xml <?xml version="1.0" encoding="utf-8"?> <book xmlns="http://docbook.org/ns/docbook" xmlns:phd="http://www.php.net/ns/phd" version="lillet" xml:id="package.webservices.services-geonames" > <info> <title>Services_GeoNames</title> <abstract> <para> <phd:pearapi phd:package="Services_GeoNames" phd:linkend="Services_GeoNames"/> is a PHP interface to the various webservices offered by the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&url.geonames.home;">GeoNames project.</link> </para> </abstract> </info> <chapter> &package.webservices.services-geonames.intro; &package.webservices.services-geonames.getting-started; &package.webservices.services-geonames.examples; </chapter> </book> http://cvs.php.net/viewvc.cgi/peardoc/en/package/webservices/services-geonames/examples.xml?view=markup&rev=1.1 Index: peardoc/en/package/webservices/services-geonames/examples.xml +++ peardoc/en/package/webservices/services-geonames/examples.xml <?xml version="1.0" encoding="utf-8"?> <refentry xmlns="http://docbook.org/ns/docbook" xmlns:phd="http://www.php.net/ns/phd" version="lillet" xml:id="package.webservices.services-geonames.examples" > <refnamediv> <refname>Examples</refname> <refpurpose>various code examples</refpurpose> </refnamediv> <refsection><info><title>Search for all cities named Paris</title></info> <para> <example> <programlisting role="php"> <![CDATA[ <?php require_once 'Services/GeoNames.php'; $geo = new Services_GeoNames(); $cities = $geo->search(array('name_equals' => 'Paris')); echo "List of cities named Paris:\n"; foreach($cities as $city) { printf(" - %s (%s)\n", $city->name, $city->countryName); } echo "\n"; ?> ]]> </programlisting> </example> </para> </refsection> <refsection><info><title>Find all postal codes near by Toulouse in a radius of 10km</title></info> <para> <example> <programlisting role="php"> <![CDATA[ <?php require_once 'Services/GeoNames.php'; $geo = new Services_GeoNames(); $postalCodes = $geo->findNearbyPostalCodes(array( 'lat' => 43.606, 'lng' => 1.444, 'radius' => 10, // 10km 'maxRows' => 100 )); echo "List of postal codes near by Toulouse in a radius of 10km:\n"; foreach ($postalCodes as $code) { printf(" - %s (%s)\n", $code->postalCode, $code->placeName); } echo "\n"; ?> ]]> </programlisting> </example> </para> </refsection> <refsection><info><title>List all countries and capitals in spanish</title></info> <para> <example> <programlisting role="php"> <![CDATA[ <?php require_once 'Services/GeoNames.php'; $geo = new Services_GeoNames(); $countries = $geo->countryInfo(array('lang' => 'es')); echo "List of all countries in spanish language:\n"; foreach ($countries as $country) { printf(" - %s (capital: %s)\n", $country->countryName, $country->capital); } echo "\n"; ?> ]]> </programlisting> </example> </para> </refsection> <refsection><info><title>List neightbours countries of France</title></info> <para> <example> <programlisting role="php"> <![CDATA[ <?php require_once 'Services/GeoNames.php'; $geo = new Services_GeoNames(); // retrieve the geonameId if we don't know it $array = $geo->countryInfo(array('country' => 'FR')); $geonameId = $array[0]->geonameId; $neighbours = $geo->neighbours(array('geonameId' => $geonameId)); echo "Neighbours of France are:\n"; foreach ($neighbours as $neighbour) { printf(" - %s\n", $neighbour->countryName); } ?> ]]> </programlisting> </example> </para> </refsection> </refentry> http://cvs.php.net/viewvc.cgi/peardoc/en/package/webservices/services-geonames/getting-started.xml?view=markup&rev=1.1 Index: peardoc/en/package/webservices/services-geonames/getting-started.xml +++ peardoc/en/package/webservices/services-geonames/getting-started.xml <?xml version="1.0" encoding="utf-8"?> <refentry xmlns="http://docbook.org/ns/docbook" xmlns:phd="http://www.php.net/ns/phd" version="lillet" xml:id="package.webservices.services-geonames.getting-started" > <refnamediv> <refname>Getting started</refname> <refpurpose>getting started with the <classname>Services_GeoNames</classname> package</refpurpose> </refnamediv> <refsection><info><title>Instanciating the <classname>Services_GeoNames</classname> class</title></info> <para> To instanciate the main class just do: <programlisting role="php"> <![CDATA[ <?php require_once 'Services/GeoNames.php'; $geo = new Services_GeoNames(); ?> ]]> </programlisting> And if you have a commercial account: <programlisting role="text"> <![CDATA[ <?php require_once 'Services/GeoNames.php'; $geo = new Services_GeoNames('your_username', 'your_authtoken'); ?> ]]> </programlisting> </para> </refsection> <refsection><info><title>Using <classname>Services_GeoNames</classname> methods</title></info> <para> To call a webservice method, just instanciate the class as described above and call the desired method with an array of parameters, for example: <programlisting role="php"> <![CDATA[ <?php require_once 'Services/GeoNames.php'; $geonames = new Services_GeoNames('username', 'some authtoken...'); $countries = $geonames->countryInfo(array('lang' => 'es')); echo "List of all countries in spanish language:\n"; foreach ($countries as $country) { printf(" - %s (capital: %s)\n", $country->countryName, $country->capital); } ?> ]]> </programlisting> Every method take an array as single parameter, for example in the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&url.geonames.apidocs;">GeoNames API documentation</link> when you see something like: <programlisting role="text"> <![CDATA[ Webservice Type : REST Url : ws.geonames.org/citiesJSON? Parameters : north,south,east,west : coordinates of bounding box callback : name of javascript function (optional parameter) lang : language of placenames and wikipedia urls (default = en) maxRows : maximal number of rows returned (default = 10) ]]> </programlisting> That means that you can call the cities() method as follows: <programlisting role="php"> <![CDATA[ <?php require_once 'Services/GeoNames.php'; $geo = new Services_GeoNames(); $cities = $geo->cities(array( 'north' => 44.1, 'south' => -9.9, 'east' => -22.4, 'west' => 55.2, 'lang' => 'de', 'maxRows' => 5, )); ?> ]]> </programlisting> Note that for convenience, some methods can take a geonameId (integer) instead of the array as unique parameter, for example, the following two calls are equivalent: <programlisting role="php"> <![CDATA[ <?php require_once 'Services/GeoNames.php'; $geo = new Services_GeoNames(); // theses two method calls are equivalent $children = $geo->children(3175395); $children = $geo->children(array('geonameId' => 3175395)); ?> ]]> </programlisting> </para> </refsection> <refsection><info><title>Available methods</title></info> <table> <title>API methods</title> <tgroup cols="3"> <thead> <row> <entry>Method name</entry> <entry>Parameters</entry> <entry>Return type</entry> </row> </thead> <tbody> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/place-hierarchy.html#children">children()</link> </entry> <entry>int geonameId or array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/JSON-webservices.html#citiesJSON">cities()</link> </entry> <entry>int geonameId or array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#countrycode">countryCode()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#countryInfo">countryInfo()</link> </entry> <entry>array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#countrysubdiv">countrySubdivision()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/JSON-webservices.html#earthquakesJSON">earthquakes()</link> </entry> <entry>array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://forum.geonames.org/gforum/posts/list/581.page#2667">findNearby()</link> </entry> <entry>array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#findNearbyPlaceName">findNearbyPlaceName()</link> </entry> <entry>array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#findNearbyPostalCodes">findNearbyPostalCodes()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/maps/reverse-geocoder.html#findNearbyStreets">findNearbyStreets()</link> </entry> <entry>array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/JSON-webservices.html#findNearByWeatherJSON">findNearByWeather()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/wikipedia-webservice.html#findNearbyWikipedia">findNearbyWikipedia()</link> </entry> <entry>array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/maps/reverse-geocoder.html#findNearestAddress">findNearestAddress()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/maps/reverse-geocoder.html#findNearestIntersection">findNearestIntersection()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/">get()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#gtopo30">gtopo30()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/place-hierarchy.html#hierarchy">hierarchy()</link> </entry> <entry>int geonameId or array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#neighbourhood">neighbourhood()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/place-hierarchy.html#neighbours">neighbours()</link> </entry> <entry>int geonameId or array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#postalCodeCountryInfo">postalCodeCountryInfo()</link> </entry> <entry></entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#postalCodeLookupJSON">postalCodeLookup()</link> </entry> <entry>array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#postalCodeSearch">postalCodeSearch()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/geonames-search.html">search()</link> </entry> <entry>array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/place-hierarchy.html#siblings">siblings()</link> </entry> <entry>int geonameId or array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#srtm3">srtm3()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/web-services.html#timezone">timezone()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/JSON-webservices.html#weatherJSON">weather()</link> </entry> <entry>array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/JSON-webservices.html#weatherIcaoJSON">weatherIcao()</link> </entry> <entry>array</entry> <entry>stdclass</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/wikipedia-webservice.html#wikipediaBoundingBox">wikipediaBoundingBox()</link> </entry> <entry>array</entry> <entry>array</entry> </row> <row> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.geonames.org/export/wikipedia-webservice.html#wikipediaSearch">wikipediaSearch()</link> </entry> <entry>array</entry> <entry>array</entry> </row> </tbody> </tgroup> </table> <table> <title>Non API methods</title> <tgroup cols="4"> <thead> <row> <entry>Method name</entry> <entry>Parameters</entry> <entry>Return type</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry> <phd:pearapi phd:package="Services_GeoNames" phd:linkend="Services_GeoNames::getSupportedEndpoints"/> </entry> <entry></entry> <entry>array</entry> <entry>returns an array of all supported services endpoints (aka methods)</entry> </row> <row> <entry> <phd:pearapi phd:package="Services_GeoNames" phd:linkend="Services_GeoNames::getRequest"/> </entry> <entry></entry> <entry>HTTP_Request2</entry> <entry>returns the Services_GeoNames request instance</entry> </row> <row> <entry> <phd:pearapi phd:package="Services_GeoNames" phd:linkend="Services_GeoNames::setRequest"/> </entry> <entry>HTTP_Request2</entry> <entry></entry> <entry>sets the Services_GeoNames request instance</entry> </row> </tbody> </tgroup> </table> </refsection> <refsection><info><title>Customizing the http request</title></info> <para> If for some reason you need a custom request, for example if you are behind a proxy, you can modify the Services_GeoNames request instance, for example: <programlisting role="php"> <![CDATA[ <?php require_once 'Services/GeoNames.php'; $geo = new Services_GeoNames(); // customize the http request $geo->getRequest()->setConfig(array( 'proxy_host' => 'localhost', 'proxy_port' => 8118, )); // now geonames uses your proxy $children = $geo->children(3175395); ?> ]]> </programlisting> For more infos please read the <phd:pearapi phd:package="HTTP_Request2" phd:linkend="HTTP_Request2"/> documentation. </para> </refsection> </refentry> http://cvs.php.net/viewvc.cgi/peardoc/en/package/webservices/services-geonames/intro.xml?view=markup&rev=1.1 Index: peardoc/en/package/webservices/services-geonames/intro.xml +++ peardoc/en/package/webservices/services-geonames/intro.xml <?xml version="1.0" encoding="utf-8"?> <refentry xmlns="http://docbook.org/ns/docbook" xmlns:phd="http://www.php.net/ns/phd" version="lillet" xml:id="package.webservices.services-geonames.intro" > <refnamediv> <refname>Introduction</refname> <refpurpose>introduction to the <classname>Services_GeoNames</classname> package</refpurpose> </refnamediv> <refsection><info><title>Introduction</title></info> <para> <phd:pearapi phd:package="Services_GeoNames" phd:linkend="Services_GeoNames"/> is a PHP interface to the various webservices offered by the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&url.geonames.home;">GeoNames project.</link> </para> <para> The GeoNames database contains over 8,000,000 geographical names corresponding to over 6,500,000 unique features. All features are categorized into one out of nine feature classes and further subcategorized into one out of 645 feature codes. Beyond names of places in various languages, data stored include latitude, longitude, elevation, population, administrative subdivision and postal codes. All coordinates use the WGS84 system (World Geodetic System 1984). </para> <para> Those data are accessible free of charge through a number of Web services and a daily database export. The Web services include direct and reverse geocoding, finding places through postal codes, finding places next to a given place, and finding Wikipedia articles about neighbouring places. </para> </refsection> <refsection><info><title>Installation</title></info> <para> To install the package with pear just do: <programlisting role="text"> <![CDATA[ $ pear install -f Services_GeoNames ]]> </programlisting> And to uninstall it: <programlisting role="text"> <![CDATA[ $ pear uninstall Services_GeoNames ]]> </programlisting> </para> </refsection> <refsection><info><title>Links</title></info> <itemizedlist> <listitem> <simpara> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&url.geonames.home;">GeoNames project homepage</link> </simpara> </listitem> <listitem> <simpara> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&url.geonames.apidocs;">GeoNames API documentation.</link> </simpara> </listitem> </itemizedlist> </refsection> </refentry>
« previous php.pear.doc (#11322) next »