ipinfo
Get http://ipinfo.io with the D programming language.
Discussion
Home page: https://github.com/workhorsy/d-ipinfo
Version
4.0.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: 203.205.28.14
latitude: 37.385999999999996
longitude: -122.0838
org: AS15169 Google Inc.
city: Mountain View
region: California
country: US
postal: 94043
*/
-
Declaration
structIpinfoData;Data gathered in
IpinfoData:struct IpinfoData { string ip; string latitude; string longitude; string org; string city; string region; string country; string postal; }
-
Declaration
voidgetIpinfo(void delegate(IpinfoData data, Exception err)cb);Returns the ipinfo info using a callback.
Parameters
void delegate(IpinfoData data, Exception err)cbThe callback to fire when the ipinfo has been downloaded. The callback sends the IpinfoData data and an Exception if there was any problem.