Maybe test with this code:

CLEAR
? GetHTTPContent("http://www.atoutfox.org/ip.asp";, .T.)
? GetHTTPContent("http://ipecho.net/plain";)

*******************************************
FUNCTION GetHTTPContent
*******************************************
LPARAMETERS cURL, lBodyOnly

LOCAL oHTTP as Msxml2.ServerXMLHTTP, cErrorText, cHTML, lErrorState
STORE "" TO cErrorText, cHTML

TRY 
        ohttp = CREATEOBJECT("Msxml2.ServerXMLHTTP")
CATCH 
        cErrortext = "Cannot instanciate MSXML2"
        lErrorstate = .t.
        ohhtp = .NULL.
ENDTRY

IF VARTYPE(oHTTP) = "O" 
        TRY
                oHTTP.OPEN("GET",cUrl,.F.)
                oHTTP.SEND()
        CATCH
                lErrorState = .T.
                cErrortext = "Open/Send failed"
        ENDTRY
ENDIF

IF NOT lErrorState
        cHtml = oHTTP.responseBody

        IF NOT INLIST(VARTYPE(cHTML),"Q","C") OR EMPTY(cHTML) 
                lErrorState = .T.
                cErrortext = "error on response"
        ELSE
                * convert unicode to utf
                cHtml = STRCONV(cHTML,9)
        ENDIF
ENDIF

IF lErrorState
        cHTML = "Error: " + cErrorText
ELSE    
        IF lBodyOnly
                cHTML = STREXTRACT(cHTML, "<body>", "</body>",1,1)
        ENDIF
ENDIF
        
RETURN cHTML


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: https://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: https://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: https://leafe.com/archives
This message: 
https://leafe.com/archives/byMID/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to