Getting the Public IP address

Devin Asay devin_asay at byu.edu
Thu Aug 8 11:09:36 EDT 2013


On Aug 8, 2013, at 4:30 AM, FlexibleLearning.com wrote:

> I am trying to establish the User's public IP address. The Scripter's
> Scrapbook has several methods, all of which return the same result and all
> of which seem to return a local IP address (e.g. put the hostnametoaddress
> of the hostname into myIP). I am getting 192.168.2.2 (local) instead of the
> required 85.210.89.23 (public). It must be possible as a google search on
> 'My IP address' displays it.
> 
> As a self-confessed die-hard IP nitwit, I have tried to research a solution
> but have failed miserably.
> 
> Has anyone got a method to obtain a User's public IP address?
> 
> Many thanks,

Hugh, if you have access to a web server with LiveCode Server on it you could check the environment variable $_SERVER["REMOTE_ADDR"]. The script would look something like this:

<?lc
  put "Remote IP Address" & ":" & $_SERVER["REMOTE_ADDR"] 
?>

I have an example on my on-rev site. Just hit http://dev.on-rev.com/myip.irev. Of course this presupposes that the end user has an active internet connection.

HTH

Devin

Devin Asay
Office of Digital Humanities
Brigham Young University





More information about the use-livecode mailing list