ipinfo
Get http://ipinfo.io with the D programming language.
Discussion
Home page: https://github.com/workhorsy/d-ipinfo
Version
1.1.0
License
Boost Software License - Version 1.0
Examples
import std.stdio : stdout, stderr;
import ipinfo : getIpinfo, IpinfoData;
getIpinfo(delegate(IpinfoData data, Exception err) {
if (err) {
stderr.writefln("%s", err);
} else {
stdout.writefln("ip: %s", data.ip);
stdout.writefln("latitude: %s", data.latitude);
stdout.writefln("longitude: %s", data.longitude);
stdout.writefln("org: %s", data.org);
stdout.writefln("city: %s", data.city);
stdout.writefln("region: %s", data.region);
stdout.writefln("country: %s", data.country);
stdout.writefln("postal: %s", data.postal);
}
});
/*
ip: 8.8.8.8
latitude: 37.385999999999996
longitude: -122.0838
org: AS15169 Google Inc.
city: Indio
region: California
country: US
postal: 94043
*/
-
Declaration
struct
IpinfoData
;Data gathered in
IpinfoData
:struct IpinfoData { string ip; string latitude; string longitude; string org; string city; string region; string country; string postal; }
-
Declaration
void
getIpinfo
(void delegate(IpinfoData data, Exception err)cb
);Returns the ipinfo info using a callback.
Parameters
void delegate(IpinfoData data, Exception err)
cb
The callback to fire when the ipinfo info has been downloaded.
Throws
If it fails to download or parse the JSON response.