1. Sivaprakash BKR
  2. PowerBuilder
  3. Friday, 18 March 2022 07:47 AM UTC

Hello,

Need to get the IP address, assigned by ISP, from an PB application.   Is it possible?  

If I go to myip.com, there we will get the IP address assigned by the ISP.  Need to get the same from an PB application.  How to get it?

Happiness Always
BKR Sivaprakash

 

Accepted Answer
Andreas Mykonios Accepted Answer Pending Moderation
  1. Friday, 18 March 2022 11:12 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi.

The most safe way, I believe is to get that information by running an internet "query".

You can try this:

httpClient lo_client
integer li_ret, li_StatusCode
long ll_ret
string ls_url
string ls_data
string ls_ret

ls_url = 'http://ipinfo.io/ip'

lo_client = Create httpClient
ll_ret = lo_client.sendrequest('get',ls_url)
li_StatusCode = lo_client.GetResponseStatusCode()

ls_ret = lo_client.GetResponseStatusText( )
li_ret = lo_client.getresponsebody(  ls_data)
destroy lo_client

messagebox("", ls_ret)
messagebox("", ls_data)

return

ls_data should contain you external ip.

Andreas.

Comment
  1. Sivaprakash BKR
  2. Friday, 18 March 2022 13:34 PM UTC
Thanks Andreas. It works.
  1. Helpful
  1. mike S
  2. Friday, 18 March 2022 14:50 PM UTC
there is another url that we use for the same purpose: https://api.ipify.org



ll_rval = lnv_http.sendrequest( 'GET', 'https://api.ipify.org')

lnv_http.getresponsebody( lblb_rval )





  1. Helpful 3
  1. Andreas Mykonios
  2. Friday, 18 March 2022 16:01 PM UTC
By the way, do preffer to use a https call as mike adviced. For the one I provided it would be https://ipinfo.io/ip.
  1. Helpful 2
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.