Reputation:
I have around 30K IP address(IPv4) in a MySQL Database.
I want to get information related to these IPs like
Country City etc.
I have tried IP-to-Country Databases which are not very accurate and are wrong for many IPs.
Web APIs do not let these many IP queries and also maybe inaccurate.
I want to have accurate information . (atleast Country should be accurate)
I have Java at Backend , PHP/HTML5 for display
Please Help .
Upvotes: 1
Views: 2034
Reputation: 33544
Try this, it works like magic...........
Key and Secret:
private final String key = "86b780aec0cee918718d7eb2fa084df412771c17";
private final String secret = "d3e3fa0a1fc6a35ac02aa591ed32ecaa750df9a7";
Method to Create the Session:
public void xmlCreateSession(){
String createSession = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+"\n"+"<request>"+"\n"+"<token>"+"</token>"+"\n"+"<key>"+this.getKey()+"</key>"+"\n"+"<secret>"+this.getSecret()+"</secret>"+"\n"+"</request>";
firingUrl = "https://int.yumzing.com/index.php?func=sessionCreate";
// firingUrl = "http://199.87.235.147/sessionCreate";
//firingUrl = "https://int.yumzing.com/sessionCreate";
String tempCreate = postData(firingUrl, createSession);
this.getMToken(tempCreate);
System.out.println("getToken value "+this.getToken());
}
Method to Find the IP:
public void xmlUserIp(){
String userIp = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+"\n"+"<request>"+"\n"+"<token>"+this.getToken()+"</token>"+"\n"+"</request>";
firingUrl = "https://int.yumzing.com/index.php?func=userIp";
String tempIp = postData(firingUrl, userIp);
this.getMIp(tempIp);
System.out.println("getToken value "+this.getIp());
}
Method to get Info based on IP:
public void xmlUserLocation(){
this.xmlUserIp();
System.out.println("With in xmlUserLocation-"+this.getToken()+" "+this.getIp());
String userLocation = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+"\n"+"<request>"+"\n"+"<token>"+this.getToken()+"</token>"+"\n"+"<ip>"+this.getIp()+"</ip>"+"\n"+"</request>";
firingUrl = "https://int.yumzing.com/?func=userLocation";
System.out.println("With in xmlUserLocation-"+this.getToken()+" "+this.getIp());
String tempLoc = postData(firingUrl, userLocation);
System.out.println("In xmluserLoc"+tempLoc);
this.getMLocation(tempLoc);
System.out.println("getToken value "+this.getCountry());
System.out.println("getToken value "+this.getState());
System.out.println("getToken value "+this.getCity());
System.out.println("getToken value "+this.getLatitude());
System.out.println("getToken value "+this.getLongitude());
}
Upvotes: 0
Reputation: 55972
I think maxmind is probably the defacto geoip database. They offer a free one that is 99.5% accurate on a country level and 78% accurate on a city level.
They have both php and java libraries. http://www.maxmind.com/app/ip-location
Upvotes: 3