How does one get IP and hostname?

Just starting out? Need help? Post your questions and find answers here.
kingwolf71
Posts: 30
Joined: Wed May 01, 2019 10:14 am

How does one get IP and hostname?

Post 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?
plouf
Posts: 295
Joined: Tue Feb 25, 2014 6:01 pm
Location: Athens,Greece

Re: How does one get IP and hostname?

Post by plouf »

Its not possible neither natuve fuctions neither via javascript
Securicy policy prohibit it
Christos
kingwolf71
Posts: 30
Joined: Wed May 01, 2019 10:14 am

Re: How does one get IP and hostname?

Post by kingwolf71 »

that's a bummer, that is
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: How does one get IP and hostname?

Post by Fred »

if you plan to get it on mobile you can use this cordova module: https://stackoverflow.com/questions/393 ... rdova-apps
kingwolf71
Posts: 30
Joined: Wed May 01, 2019 10:14 am

Re: How does one get IP and hostname?

Post 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)

plouf
Posts: 295
Joined: Tue Feb 25, 2014 6:01 pm
Location: Athens,Greece

Re: How does one get IP and hostname?

Post 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
Christos
Post Reply