Technology has always been a bridge, but today, it feels more like a mirror. With the rapid rise of AI , we are seeing things enter our lives and leave them at a pace we can barely track. To understand where this is going, we first have to understand how technology actually impacts the core of who we are. The Survivalist vs. The Ego Our minds are biologically wired for one thing: survival . We are designed to handle the worst-case scenario, an ancient instinct gifted to us by nature. We consider ourselves conscious decision-makers, but a critical question remains: Who is really making the call?
Here is sample code to get IP (internet protocol) details in single click using Visualforce page and apex class in salesforce.
https://freegeoip.app/
This is a free tool for finding IP address geo location. The database contains the following details: Country (code/name), Region (code/name), City etc.
Visualforce Page:-
This is a free tool for finding IP address geo location. The database contains the following details: Country (code/name), Region (code/name), City etc.
| IP Details |
Visualforce Page:-
<apex:page controller="IPlocationtrack" docType="html-5.0" lightningStylesheets="true">
<head>
<apex:slds />
</head>
<div class="slds-scope">
<apex:form id="out">
<apex:input value="{!ipinput}"/>
<apex:commandButton title="Get IP" action="{!ipfetch}" value="get IP" reRender="out" id="button"/>
<table class="slds-table slds-table_cell-buffer slds-table_bordered">
<thead>
<tr class="slds-line-height_reset">
<th class="" scope="col">
<div class="slds-truncate">IP</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">country_code</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">country_name</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">region_code</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">region_name</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">city</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">zip_code</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">time_zone</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">latitude</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">longitude</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">metro_code</div>
</th>
</tr>
</thead>
<tbody>
<tr class="slds-hint-parent">
<th data-label="Opportunity Name" scope="row">
<div class="slds-truncate" title="Cloudhub">
<a href="javascript:void(0);" tabindex="-1">{!objcls.ip} </a>
</div>
</th>
<td data-label="Account Name">
<div class="slds-truncate" title="">{!objcls.country_code}</div>
</td>
<td data-label="Close Date">
<div class="slds-truncate" title="">{!objcls.country_name}</div>
</td>
<td data-label="Prospecting">
<div class="slds-truncate" title="">{!objcls.region_code}</div>
</td>
<td data-label="Confidence">
<div class="slds-truncate" title="">{!objcls.region_name}</div>
</td>
<td data-label="Amount">
<div class="slds-truncate" title="">{!objcls.city}</div>
</td>
<td data-label="Contact">
<div class="slds-truncate" title="">
<a href="javascript:void(0);" tabindex="-1">{!objcls.zip_code}</a>
</div>
</td>
<td data-label="Contact">
<div class="slds-truncate" title="">
<a href="javascript:void(0);" tabindex="-1">{!objcls.time_zone}</a>
</div>
</td>
<td data-label="Contact">
<div class="slds-truncate" title="">
<a href="javascript:void(0);" tabindex="-1">{!objcls.latitude}</a>
</div>
</td>
<td data-label="Contact">
<div class="slds-truncate" title="">
<a href="javascript:void(0);" tabindex="-1">{!objcls.longitude}</a>
</div>
</td>
<td data-label="Contact">
<div class="slds-truncate" title="">
<a href="javascript:void(0);" tabindex="-1">{!objcls.metro_code}</a>
</div>
</td>
</tr>
</tbody>
</table>
</apex:form>
</div>
public class IPlocationtrack {
public string ipinput{get;set;}
public IPlocationtrack.IPdetails objcls{get;set;}
public IPlocationtrack (){
ipinput='';
}
public void ipfetch(){
Http http = new Http();
HttpRequest request = new HttpRequest();
if(ipinput!=null || ipinput!=''){
request.setEndpoint('https://freegeoip.app/json/'+ipinput);
}else{
request.setEndpoint('https://freegeoip.app/json/');
}
request.setMethod('GET');
HttpResponse response = http.send(request);
objcls= (IPdetails)JSON.deserialize(response.getbody(), IPdetails.class);
}
public class IPdetails{
public String ip{get;set;}
public String country_code {get;set;}
public String country_name {get;set;}
public String region_code {get;set;}
public String region_name {get;set;}
public String city {get;set;}
public String zip_code {get;set;}
public String time_zone {get;set;}
public Double latitude {get;set;}
public Double longitude {get;set;}
public Integer metro_code {get;set;}
}
<head>
<apex:slds />
</head>
<div class="slds-scope">
<apex:form id="out">
<apex:input value="{!ipinput}"/>
<apex:commandButton title="Get IP" action="{!ipfetch}" value="get IP" reRender="out" id="button"/>
<table class="slds-table slds-table_cell-buffer slds-table_bordered">
<thead>
<tr class="slds-line-height_reset">
<th class="" scope="col">
<div class="slds-truncate">IP</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">country_code</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">country_name</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">region_code</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">region_name</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">city</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">zip_code</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">time_zone</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">latitude</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">longitude</div>
</th>
<th class="" scope="col">
<div class="slds-truncate">metro_code</div>
</th>
</tr>
</thead>
<tbody>
<tr class="slds-hint-parent">
<th data-label="Opportunity Name" scope="row">
<div class="slds-truncate" title="Cloudhub">
<a href="javascript:void(0);" tabindex="-1">{!objcls.ip} </a>
</div>
</th>
<td data-label="Account Name">
<div class="slds-truncate" title="">{!objcls.country_code}</div>
</td>
<td data-label="Close Date">
<div class="slds-truncate" title="">{!objcls.country_name}</div>
</td>
<td data-label="Prospecting">
<div class="slds-truncate" title="">{!objcls.region_code}</div>
</td>
<td data-label="Confidence">
<div class="slds-truncate" title="">{!objcls.region_name}</div>
</td>
<td data-label="Amount">
<div class="slds-truncate" title="">{!objcls.city}</div>
</td>
<td data-label="Contact">
<div class="slds-truncate" title="">
<a href="javascript:void(0);" tabindex="-1">{!objcls.zip_code}</a>
</div>
</td>
<td data-label="Contact">
<div class="slds-truncate" title="">
<a href="javascript:void(0);" tabindex="-1">{!objcls.time_zone}</a>
</div>
</td>
<td data-label="Contact">
<div class="slds-truncate" title="">
<a href="javascript:void(0);" tabindex="-1">{!objcls.latitude}</a>
</div>
</td>
<td data-label="Contact">
<div class="slds-truncate" title="">
<a href="javascript:void(0);" tabindex="-1">{!objcls.longitude}</a>
</div>
</td>
<td data-label="Contact">
<div class="slds-truncate" title="">
<a href="javascript:void(0);" tabindex="-1">{!objcls.metro_code}</a>
</div>
</td>
</tr>
</tbody>
</table>
</apex:form>
</div>
</apex:page>
Apex Class:-public class IPlocationtrack {
public string ipinput{get;set;}
public IPlocationtrack.IPdetails objcls{get;set;}
public IPlocationtrack (){
ipinput='';
}
public void ipfetch(){
Http http = new Http();
HttpRequest request = new HttpRequest();
if(ipinput!=null || ipinput!=''){
request.setEndpoint('https://freegeoip.app/json/'+ipinput);
}else{
request.setEndpoint('https://freegeoip.app/json/');
}
request.setMethod('GET');
HttpResponse response = http.send(request);
objcls= (IPdetails)JSON.deserialize(response.getbody(), IPdetails.class);
}
public class IPdetails{
public String ip{get;set;}
public String country_code {get;set;}
public String country_name {get;set;}
public String region_code {get;set;}
public String region_name {get;set;}
public String city {get;set;}
public String zip_code {get;set;}
public String time_zone {get;set;}
public Double latitude {get;set;}
public Double longitude {get;set;}
public Integer metro_code {get;set;}
}
}