Avatar of Graeme McGilvray
Graeme McGilvray
Flag for Australia

asked on 

API giving strange outputs

Hi all, I have an API to define my external IP, however the server is local hosting the site, is giving out the SERVER WAN IP, not the client IP

    Set oXMLHTTPLoc=CreateObject("MSXML2.ServerXMLHTTP")
    LocAPI="http://api.ipify.org/"
    oXMLHTTPLoc.Open "GET",LocAPI,False
    oXMLHTTPLoc.Send
    If oXMLHTTPLoc.Status="200" Then
      IP=oXMLHTTPLoc.responseText
      LocAPI="http://ip-api.com/json/"&IP&"?fields=countryCode,city"
	    oXMLHTTPLoc.Open "GET",LocAPI,False
	    oXMLHTTPLoc.Send
	    If oXMLHTTPLoc.Status="200" Then
		    GetTextFromUrlLoc=oXMLHTTPLoc.responseText
		    CityLoc=Replace(Split(Split(GetTextFromUrlLoc,",")(0),":")(1),"""","")
        CountryLoc=Replace(Replace(Split(Split(GetTextFromUrlLoc,",")(1),":")(1),"""",""),"}","")
	    End If
    End If	

Open in new window


The reason I have it set up like this is so that when I browse the site, it doesnt grab my LAN address (192.168.0.x)

I just would like it to grab the client IP address
ASP

Avatar of undefined
Last Comment
Graeme McGilvray

8/22/2022 - Mon