+
+ function getGeonames($method, $params)
+ {
+ $client = HTTPClient::start();
+
+ $result = $client->get($this->wsUrl($method, $params));
+
+ if (!$result->isOk()) {
+ throw new Exception("HTTP error code " . $result->code);
+ }
+
+ $document = new SimpleXMLElement($result->getBody());
+
+ if (empty($document)) {
+ throw new Exception("No results in response");
+ }
+
+ if (isset($document->status)) {
+ throw new Exception("Error #".$document->status['value']." ('".$document->status['message']."')");
+ }
+
+ // Array of elements
+
+ return $document->geoname;
+ }
+
+ function onPluginVersion(&$versions)
+ {
+ $versions[] = array('name' => 'Geonames',
+ 'version' => STATUSNET_VERSION,
+ 'author' => 'Evan Prodromou',
+ 'homepage' => 'http://status.net/wiki/Plugin:Geonames',
+ 'rawdescription' =>
+ _m('Uses <a href="http://geonames.org/">Geonames</a> service to get human-readable '.
+ 'names for locations based on user-provided lat/long pairs.'));
+ return true;
+ }