Hi,
I'm playing around with Zink reading the geo location of any IP-address.
Evaluating the code below in a playground works fine. But what is the best
way to read the entity data of the ZnResponse instance I get back. Have I to
parse it, with an self written parser, or is there anything available.

|client znResponse location|
client := ZnClient new.
client host: 'www.geoplugin.net'.
client addPathSegment: 'php.gp'.
client queryAt: 'ip' put: '188.194.228.195'.
znResponse := client get; response.

The code should anyhow look like this.
AnyParser parse: (ReadStream on: znResponse contents).

In PHP the example code is at http://www.geoplugin.com/webservices/php
var_export(unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=188.194.228.195])));
I'm searching for the unserialize of the php, which delivers an array with
key value pairs.


The response entity contents looks somehow like the bottom string without
the newlines.
'a:18:{
s:17:"geoplugin_request";s:15:"188.194.228.195";
s:16:"geoplugin_status";i:200;
s:16:"geoplugin_credit";s:145:"Some of the returned data includes GeoLite
data created by MaxMind, available from  http://www.maxmind.com
<\'http://www.maxmind.com\'>  .";
s:14:"geoplugin_city";s:6:"Passau";
s:16:"geoplugin_region";s:7:"Bavaria";
s:18:"geoplugin_areaCode";s:1:"0";
s:17:"geoplugin_dmaCode";s:1:"0";
s:21:"geoplugin_countryCode";s:2:"DE";
s:21:"geoplugin_countryName";s:7:"Germany";
s:23:"geoplugin_continentCode";s:2:"EU";
s:18:"geoplugin_latitude";s:7:"48.5833";
s:19:"geoplugin_longitude";s:7:"13.4833";
s:20:"geoplugin_regionCode";s:2:"02";
s:20:"geoplugin_regionName";s:7:"Bavaria";
s:22:"geoplugin_currencyCode";s:3:"EUR";
s:24:"geoplugin_currencySymbol";s:7:"&#8364;";
s:29:"geoplugin_currencySymbol_UTF8";s:3:"€";
s:27:"geoplugin_currencyConverter";s:6:"0.9348";}'

Thanks for any help
cjb





--
View this message in context: 
http://forum.world.st/Zink-geo-location-data-reading-tp4951446.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply via email to