假设您的应用程序与其使用条款在商业上兼容,我想知道您是否可以使用 Google 的 gecoder 服务来查找邮政编码,然后检查结果以查看它是否存在。我假设如果你得到一个邮政编码和一个健全的 lat, lng 对,你可以断定邮政编码是真实的。
下面的代码(诚然使用现已弃用的 V2 API 显示了一种以美国为中心的搜索方法)。优点是最终用户和 Google 计算资源和带宽用于进行验证。
我不知道这对您的目的是否有点沉重,尽管我发现 Google 的 gecoder 速度非常快。
gecoder = new GClientGeocoder();
geocoder.getLocations(zipcode, function(response) {
if (response && response.Status.code === 200) {
var places = response.Placemark;
for (var p in places) {
if (places[p].AddressDetails.Country.CountryNameCode === 'US') {
// lat => places[p].Point.coordinates[1],
// lng => places[p].Point.coordinates[0],
// zip => places[p].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber
}
}
}
});