Read on before you say this is a duplicate, it\'s not. (as far as I could see)
I want to get the county code in php from the client.
Yes I know you can do th
Whois is just a client for the whois service, so technically you are still relying on an outside site. For the queries that fail, you could try falling back to another site for the query, such as hostip.info, who happen to have a decent API and seem friendly:
http://api.hostip.info/country.php?ip=4.2.2.2
returns
US
Good luck,
--jed
EDIT: @Mint Here is the link to the API on hostip.info: http://www.hostip.info/use.html