BlogAll Blog Posts | Next Post | Previous Post
Wednesday, October 06, 2021
You would be amazed to find out how much detailed and accurate information you can retrieve from an IP address. Collecting data based on the IP address can be key to various parts of your business. Want to know where your customers are located during an online meeting? Want to include this technology in your application to gather statistical data and don't know exactly how to get started? The TTMSFNCCloudIPLocalization component (part of the TMS FNC Cloud Pack) is designed to retrieve detailed and accurate information from an IP address and is capable of doing this via the IP Geolocation API from Abstract.
The TTMSFNCCloudIPLocalization component is able to retrieve the following information from an IP address.
- Country name, code & flag image
- Region name & code
- Virtual Private Network (VPN) detection
- Internet Service Provider (ISP) information
- Latitude & Longitude
- Timezone information
The code snippets below are based on the IP Geolocation API from Abstract to retrieve the information we want to visualize. To get started, you will need to create a free account. After logging in, go to dashboard, select IP Geolocation. The process only takes a couple of seconds, afterwards you can copy the API key which is required to work with the TTMSFNCIPLocalization component. Below you can see the page you get after setting up your account.
The above steps is all we need to do get started with the TTMSFNCIPLocalization component. Drop an instance of TTMSFNCIPLocalization on the form. Set the API key and set the service property. (Replace 'MyAPIKey' with a valid API key).
TMSFNCCloudIPLocalization1.APIKey := 'MyAPIKey'; TMSFNCCloudIPLocalization1.Service := ipsAbstractAPI; TMSFNCCloudIPLocalization1.OnGetIP := DoGetIP;
After assigning the OnGetIP event, add a button with the following code to retrieve your own IP address.
Alternatively, you can also add a custom IP address. This can be done with the following code. (Replace 'x.x.x.x' with a valid IP address)
After clicking the button, calling the GetIP procedure, the OnGetIP event will be triggered. In this event, we have immediate access to the information retreive from the IP address. Backtracing which IP address was requested can be done via AIP.IPAddress
procedure TGetIPDataForm.DoGetIP(Sender: TObject; AIP: TTMSFNCCloudIPLocalizationIP; AError: Boolean; const ARequestResult: TTMSFNCCloudBaseRequestResult); begin //retrieve IP address information via the AIP parameter end;
Below is an overview of the properties that are available when using the AIP parameter after the request has finished executing.
Included in the distribution is a demo, which shows the capabilities of the TTMSFNCCloudIPLocalization component. Below is a screenshot of the demo in action. Note that the IP address and coordinates have been blurred for privacy reasons.
The blog post focuses on the IP Geolocation API from Abstract, but the TTMSFNCCloudIPLocalization component is also capable of connecting to the following additional services. The account creation and API retrieval process is different for each service, but the way the component operates remains identical. To select one of the other services, set the Service property to either ipsIPData or ipsIPStack and set the API key for that specific service.
The TTMSFNCCloudIPLocalization component is available in the latest update, available today. So go ahead and download the latest version of the TMS FNC Cloud Pack. The TMS FNC Cloud Pack is part of the FNC family, so as a reminder, below is an overview of what FNC has to offer.
TMS FNC Components can be used simultaneously on these frameworks
TMS FNC Components can be used simultaneously on these operating systems/browsers
TMS FNC Controls can be used simultaneously on these IDEs
This blog post has received 1 comment.
All Blog Posts | Next Post | Previous Post