URL_DOMAIN
URL_DOMAIN
Domain portion of the freeGoIP API URL.
A PHP wrapper for FreeGoIP reverse geocoding API.
freegeoip.net is a service providing a public HTTP API for software developers to search the geolocation of IP addresses. It uses a database of IP addresses associated to cities along with other relevant information such as time zone, latitude and longitude. The freegeoip web server is free and open source but the public service limit up to 10,000 queries per hour by default. Once this limit is reached, all requests from the IP will result in HTTP 403, forbidden, until the quota is cleared.
__construct(string $ipaddress = '', string $domain = '', string $format = self::FORMAT_JSON) : \FreeGoIP
Constructor. The request is not executed until `queryLocation()` is called.
If neither IP address nor domain is provided, the visitor's IP address is used to reverse geocoding
string | $ipaddress | IP address to reverse geocode. |
string | $domain | Domain to reverse geocode (ignored if an IP address is provided). |
string | $format | optional response format (default: JSON) |
setFormat(string $format = 'json') : \FreeGoIP
Set the response format to use for reverse geocoding (csv,xml,json,jsonp)
string | $format | response format |
setIPAddress(string $ipaddress) : \FreeGoIP
Set the IP address to reverse geocode.
string | $ipaddress | IP address to reverse geocode |
setDomain(string $domain) : \FreeGoIP
Set the domain to reverse geocode.
string | $domain | Domain to reverse geocode |
setScheme(string $scheme) : \FreeGoIP
Set the URL scheme to use.
string | $scheme | URL scheme to use (https or http) |
queryReverseGeocoding(boolean $raw = false, resource $context = null) : string|array|\SimpleXMLElement
Execute the reverse geocoding request. The return type is based on the requested format: associative array if JSON or CSV, SimpleXMLElement object if XML. If raw is true, the raw string response will be returned.
Queries are performed using cURL and, if not available, using file_get_contents()
boolean | $raw | whether to return the raw (string) response |
resource | $context | stream context from |
The geocoding response in requested format