Page 1 of 1

How does one get IP and hostname?

Posted: Mon May 13, 2024 2:00 pm
by kingwolf71
This sounds like an easy question, but haven't really managed it
how do I get the PC/device name and IP address with spiderbasic?

Re: How does one get IP and hostname?

Posted: Mon May 13, 2024 6:52 pm
by plouf
Its not possible neither natuve fuctions neither via javascript
Securicy policy prohibit it

Re: How does one get IP and hostname?

Posted: Tue May 14, 2024 1:03 pm
by kingwolf71
that's a bummer, that is

Re: How does one get IP and hostname?

Posted: Wed May 15, 2024 7:48 am
by Fred
if you plan to get it on mobile you can use this cordova module: https://stackoverflow.com/questions/393 ... rdova-apps

Re: How does one get IP and hostname?

Posted: Sat May 25, 2024 12:42 pm
by kingwolf71
thanks @Fred and sorry for late reply

I have used this for public IP

Code: Select all

 ;Example code to get the user's public IP address using an external API
 
  Procedure HttpGetEvent(Success, Result$, UserData)
     If Success
        if UserData = 1
           if ParseJSON(0,Result$)
              ObjectValue = JSONValue(0)
              NewMap Options()
              ExtractJSONMap(JSONValue(0), Options())
              FreeJSON(0)
              debug "JSON: " + Options("ip")              
           endif
        else
           Debug Result$
        endif
    Else
      Debug "HTTPRequest(): Error"
    EndIf
  EndProcedure

  HTTPRequest(#PB_HTTP_Get, "https://api.ipify.org", "", @HttpGetEvent(), 0)
  HTTPRequest(#PB_HTTP_Get, "https://api.ipify.org", "format=json", @HttpGetEvent(),1)
  HTTPRequest(#PB_HTTP_Get, "https://api64.ipify.org", "", @HttpGetEvent(), 0)
  HTTPRequest(#PB_HTTP_Get, "https://api64.ipify.org", "format=json", @HttpGetEvent(),1)


Re: How does one get IP and hostname?

Posted: Sun May 26, 2024 7:21 am
by plouf
very well, just keep in mind that
a this provides EXTERNAL ip not local (dont know know if that you ask for)

also under many systems will be blocked since you cannot access other domains than yours

if you want to get external IP, only guaranteed method is to host a server side script (php for example) in you SAME domain server, and ask this from your script