function GetUrlContent(
const Url:
string): ApiResults;
var
tmp: UTF8String;
sl: TStrings;
begin
tmp := GetUrlContentData(
Url+'
?fields=status,country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,reverse,mobile,proxy,query,message');
try
sl := TStringList.Create;
sl.Text := tmp;
Result.Status := sl[0];
if Pos('
fail', LowerCase(Result.Status)) > 0
then
begin
Result.ErrorMessage := sl[1];
Result.QueryIP := sl[2];
end
else
begin
Result.Country := sl[1];
Result.CountryCode := sl[2];
Result.RegionState := sl[3];
Result.RegionName := sl[4];
Result.City := sl[5];
Result.Zip := sl[6];
Result.Latitude := sl[7];
Result.Longitude := sl[8];
Result.CityTimeZone := sl[9];
Result.ISP := sl[10];
Result.Organization := sl[11];
Result.NumberName := sl[12];
Result.DNS := sl[13];
Result.MobileConnection := sl[14];
Result.ProxyConnection := sl[15];
Result.QueryIP := sl[16];
end;
finally
sl.Free;
tmp := '
';
end;
end;