get possible house numbers for a postcode - php

You see them on shopping carts etc, you type in your postcode and it gives you a list of house numbers, then the user selects the house number from the list... Is this just done with a database or is there anyway to do this using google maps or another api?
this is for the UK

I have implemented this before for clients. The only reliable way i found was to use a comercial API. the cheapest and most reliable i found to be "postcodeAnywhere"
http://www.postcodeanywhere.co.uk/

You will have to use an external web service to accomplish this.
As it is for UK only, that makes it easier, but there are no free API's which will do it.
You can however fill in the rest of an address (minus house number/name) using just the Post Code by accessing the google web service:
http://code.google.com/apis/maps/documentation/geocoding/#GeocodingRequests
This is free as long as you do not plan to have large numbers of requests per year.

Related

How to get the user's country without requesting it to other web services?

I have to develop a service similar ( but different ) to these:
whatismyipaddress.com
iplocation.net
So, how can I get the country of the users by using their ip address and without using external web services ?
Try Geo IP Location . It uses offline database. But it won't be 100% accurate.
You can use ip to country data base. you can get it from Maxmind, IP2Location, software77, Maxmind, Geolite, ip2nation. some of free and some is paid. you can buy database from here.
Well, you will always need a third party, you might need to make a dictionary for countries allocated IP ranges and check for each visit the range it belongs to.
This also won't be accurate 100%, but maybe 95%.
A website that gives ip ranges to begin with: https://www.countryipblocks.net/country_selection.php
Below are the two free database commonly used by developers.
IP2Location LITE
http://lite.ip2location.com
GeoLite2
http://dev.maxmind.com/geoip/geoip2/geolite2/
Both required attribution for usage.

How to scrape amazon search with php?

Any ideas? I am new to php and am having a lot of trouble with curl and domdocuments so please write or show me an example. I was thinking of using dom documents but I can not figure out how to get amazon to search a users input from my site and display certain parts of the results such as price, category ex.....
There are several methods using file_get_contents, a "save html" plugin (https://simplehtmldom.sourceforge.io/) and CURL which I've had varying luck with, but eventually it starts flagging my requests with robot checks. I originally used the API, but Amazon locked that down to minimum traffic rules that I can't meet with my budding webservice rendering that useless.
There currently is no easy/effective way to consistently pull Amazon data though I'm playing with randomizing useragents and using proxies.
Use the Product Advertising API instead of scraping. http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemSearch.html
The product API actually would be the best resource for this although it gives you limited results and after 180 days if no affiliate transaction occurs I believe they may revoke your access so it does limit you to some extent depending on your uses. Not sure but I think you may need a professional seller account or an affiliate membership, not 100% on that but that is my understanding.

How to make a PHP based script for finding UK addresses by entering postcode?

I've almost looked everywhere but nothing found, so my only hope would be here though! :(
I want to make a PHP based script for finding UK address by entering postcode, so a list would show with a number of houses' numbers!
Any idea how I could do that, I know that I must use API, even though I search for Google Maps API for this, but nothing found whatsoever!
Any idea?
I need this particular script for an additional registration script which allows uk residents to be able to register for a specific reason, so please help if you know where I could get started!
Thanks in advance! :)
Generally these systems utilise the Royal Mail PAF database, but this does cost quite a lot of money.
There are services out there that offer X amount of requests for a set price (or a monthly price), so if buying the full thing isn't an option then you could have a look into one of those services.
It is something you are going to need to spend money on though - it's not a service that anyone (that I've ever found) is offering for free.
I don't think this is something you can get out of Google maps either.
Well, there are quite a few projects working on this dataset - just look at e.g. http://www.freethepostcode.org/ and the associated projects.
You can fetch the postcode latitude and longitude using google api:
http://maps.googleapis.com/maps/api/geocode/json?address=(POSTCODE HERE)&sensor=false
then using the lat and long from that you can get the street name
http://maps.googleapis.com/maps/api/geocode/json?latlng=(LAT),(LNG)&sensor=false
see reference here:
http://code.google.com/apis/maps/documentation/geocoding/
We can get all UK addresses by postal code with api.getaddress.io API. You can found an example on https://usingphp.com/post/how-to-get-all-uk-addresses-by-postal-code

How do I validate country and state/province names and postal codes?

I am building an web app (with PHP) that requires users to subscribe. I would like for them to identify where they are from. So what is the best way to validate there country/state(or province)/city/postal code? Is there a DB with all the information? Which one is the best?
There are many options for address validation. The main issue is how much traffic your website will receive and whether or not you need support. If you are relatively small, you can get away with the free services like the following:
Google Maps API (example) (you may be breaking the TOS)
UPS Address Verification API (example)
USPS Address Web Tools
If you need something more robust or customizable, it will probably be necessary to pay for a service.
I know this is old, but to prevent others from going down the wrong path, the chosen answer to use Google API's may not have been aware of the google terms of service license (...the Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited.)
If you're not using a map...
and your requirements do not require commercial grade data, this sums up some options and what to look for.
however, if you need commercial data, greatdata.com and melissadata.com both sell real commercial level data products.
This thread is also helpful: stackoverflow thread on zip code data
Use the Google Geocoding API They allow 2,500 requests per day and you can pay for more. It will take an address and give you very detailed information on it and provide validation if you code it into your application.
Use the USPS Address Information API.
I've utilized data that can be purchased inexpensively from http://zipcodedownload.com/ to provide zip code validation/address correction in our applications.

Recommend a web service that handles location within a specific radius?

We have a client that wants a store locator on their website. I've been asked to find a webservice that will allow us to send a zipcode as a request and have it return locations within x radius. We found this, but it's maintained by a single person, and doesn't look like it gets updated or supported very well. We're looking for something commercial, ideally that updates their zipcode database at least once per quarter, and that has a well-documented API with PHP accessibility. I won't say price isn't an object, but right now we just want some ideas, and my google-fu has failed me.
I've already posted this over on the webmasters forum, but thought I'd cover my bases and post here too.
I've repurposed this outstanding script to conquor this same challenge. It's free, has been very reliable, and is relatively quick.
In my script, I have addresses stored in the DB. So rather than show a page to enter addresses, I simply pass them as a string and let the magic happen.
He says it in the app, but ensure that if you go this route you get your own Google Maps API. It won't work with his!
If you want to go a bit less technical approach, here's a MySQL query you could run on your locations (you'd have to add lat/long to your DB or setup a GEOCODING service) to give you distance as the crow flies.
Google Maps has a geocoder as well and it geocodes to the specific address.
It's limited to x number of requests but that shouldn't be a big deal if your site is small and if you cache. You can get more requests if you pay.
It can be accessed via javascript or via PHP (and there are several prewritten PHP modules out there)
Link here:
http://code.google.com/apis/maps/documentation/javascript/v2/services.html
(I worked for a company that did upwards of 800,000 requests a day, so it's stable and fast :) )
PostcodeAnywhere has a Store Locator feature - I think it's pay per use, but I've used their other products before and they're very cheap.
http://www.postcodeanywhere.co.uk/store-locator-tool/

Categories