Tech Tip: Native 4D code to get External / Public IP address
PRODUCT: 4D | VERSION: 13.6 | PLATFORM: Mac & Win
Published On: June 4, 2015
Here is a method using native 4D commands (not using LEP or PHP) that will return the external / public IP address of the machine the code is ran from.
C_TEXT($0;$Addr_T) C_LONGINT($httpStatusCode_li) $httpStatusCode_li:=HTTP Get("https://api.ipify.org";$Addr_T) $0:=$Addr_T |
If the code above is saved to a method named UTIL_WhatIsMyIP you can use the code like this:
ALERT("The external IP address of this machine is: "+UTIL_WhatIsMyIP) |
Alternative websites to use other than api.ipify.org could be:
http://icanhazip.com
http://checkip.dyndns.com
and many more!
See Also: