MySQLデータベースに約30KのIPアドレス(IPv4)があります。
これらのIPに関連する情報を次のように取得したい
カントリーシティなど
私はIP-to-Countryデータベースを試しましたが、これはあまり正確ではなく、多くのIPで間違っています。
Web APIは、これらの多くのIPクエリを許可せず、不正確になる可能性もあります。
正確な情報が欲しい。(少なくとも国は正確である必要があります)
バックエンドにJava、表示用にPHP/HTML5があります
助けてください 。
MySQLデータベースに約30KのIPアドレス(IPv4)があります。
これらのIPに関連する情報を次のように取得したい
カントリーシティなど
私はIP-to-Countryデータベースを試しましたが、これはあまり正確ではなく、多くのIPで間違っています。
Web APIは、これらの多くのIPクエリを許可せず、不正確になる可能性もあります。
正確な情報が欲しい。(少なくとも国は正確である必要があります)
バックエンドにJava、表示用にPHP/HTML5があります
助けてください 。
maxmindはおそらく事実上のgeoipデータベースだと思います。国レベルで99.5%正確で、都市レベルで78%正確な無料のものを提供します。
彼らはphpとjavaの両方のライブラリを持っています。 http://www.maxmind.com/app/ip-location
これを試してみてください、それは魔法のように機能します..........。
キーと秘密:
private final String key = "86b780aec0cee918718d7eb2fa084df412771c17";
private final String secret = "d3e3fa0a1fc6a35ac02aa591ed32ecaa750df9a7";
セッションを作成する方法:
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());
}
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());
}
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());
}