Managing Widgets in WS.WebTV
support, ws.webtv, home, configuration, geoip, geo, ip
The function of a GeoIP service is to find the geographical location of an user from its IP addres. This sevice is required by the Site/Geo Blocking extension and used by the user management system.
This service is configured from the "GeoIP" tab, in the WebTV Configuration section:
• Provider: (Since WS.WebTV 3.0.3). This option will only be displayed if the PHP GeoIP extension is enabled in your server, and it will allow you to select the provider/system used for getting the country code from the user IP.
NOTE:
If you select "PHP" the options "Service URL" and "Response Data Index for Country Code", that you'll find below, won't be displayed.
• External Provider: The GeoIP service must support requests using GET and return the response in JSON or JSONP format (the later requires WS.WebTV 3.0). Example of GeoIP services that you can use (to name a few - some are free, others don't):
- Really Free GEO IP API (https://reallyfreegeoip.org/)
- ipstack (https://ipstack.com)
- geoPlugin (http://www.geoplugin.com/faq)
- ip-api (http://ip-api.com)
- IPInfoDB (https://www.ipinfodb.com/api)
- ipinfo.io (https://ipinfo.io)
- BigDataCloud (https://www.bigdatacloud.com/)
Developers:
If you are a developer, you can build your own GeoIP script. For this, you will need to download an IP Geolocation Database from Internet and implement a script which accepts the IP as a GET variable (Example, http://.../my_geoip_script.php?ip=xxx.xxx.xxx.xxx), then match the IP agaist your Geolocation database in order to find the geographical location and return the result (country code and -optionally- region code) in JSON format. NOTE: Make sure the country code and region code are not nested into an array or another object. Example of supported response:
{"country_code":"ES","region_code":"VC"}
After the previous, you just need to provide the URL to the script and country code data index
as explained below.
• Service URL: This is the URL where the GeoIP service receive the requests from the WebTV. Enter the service URL replacing the IP address with "{ip}". For example: if your service URL is http://my_geo_ip_serv.com/json?ip=xxx.xxx.xxx.xxx then you must enter http://my_geo_ip_serv.com/json?ip={ip}
• Response Data Index for Country Code: Specify the data index that has to be used to get the country code from the JSON response.
• Response Data Index for Region Code: (Since WS.WebTV 52) Specify the data index that has to be used to get the region code from the JSON response.
Below you'll find what you need to enter into these fields, in order to use the aforementioned GeoIP services.
WARNING: THE REGION CODE MAY BE DIFFERENT DEPENDING ON THE GEOIP SERVICE BEING USED
• Test Result: When there is no GeoIP service configured, or when it is not correctly configured, the WebTV won't be able to determine the country and the response in the information "black box" may be empty, like the following example:
When the GeoIP service has been correctly the WebTV will be able to determine the country and the full response from the GeoIP service will appear in the information "black box", like the following example:
GeoIP service configuration examples for popular services:
Really Free GEO IP API - Info: https://reallyfreegeoip.org/
- Service URL: https://reallyfreegeoip.org/json/{ip}
- Response data index for country code: country_code
- Response data index for region code: region_code
ipstack - Info: https://ipstack.com/faq
- Service URL: http://api.ipstack.com/{ip}?access_key=«api_key»
NOTE: Replace «api_key» with the API key provided by the service
- Response data index for country code: country_code
- Response data index for region code: region_code
geoPlugin (replaced by ipstack) - Info: http://www.geoplugin.com/faq
- Service URL: http://www.geoplugin.net/json.gp?ip={ip}
- Response data index for rountry code: geoplugin_countryCode
- Response data index for region code: geoplugin_regionCode
ip-api - Info: http://ip-api.com/
- Service URL: http://ip-api.com/json/{ip}
- Response data index for country code: countryCode
- Response data index for region code: region
IPInfoDB - Info: http://www.ipinfodb.com/ip_location_api_json.php
- Service URL: http://api.ipinfodb.com/v3/ip-country/?key=«api_key»&ip={ip}&format=json
NOTE: Replace «api_key» with the API key provided by the service
- Response data index for country code: countryCode
- Response data index for region code: N/A
ipinfo.io - Info: http://ipinfo.io/
- Service URL: http://ipinfo.io/{ip}
- Response data index for country code: country
- Response data index for region code: N/A
BigDataCloud - Info: https://www.bigdatacloud.com/
- Service URL: https://api.bigdatacloud.net/data/ip-geolocation?ip={ip}&localityLanguage=en&key=«api_key»
NOTE: Replace «api_key» with the API key provided by the service
- Response data index for country code: country.isoAlpha2
- Response data index for region code: location.isoPrincipalSubdivisionCode
For those cases where your GeoIP service incorrectly identifies the country for certain IP, here you can specify the correct relationship between them.
• One entry per line.
• Each entry must be in the following format [IP ADDRESS]/[COUNTRY CODE] or [IP ADDRESS]/[COUNTRY CODE]-[REGION CODE]
Examples:
- No region code: 193.144.127.85/ES
- With region code: 193.144.127.85/ES-VC