FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Send an http request
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Send an http request
Posted: Sun Apr 26, 2009 04:22 PM

Hi all,
I need to send an http request (GET method) like this:

http://softwarexp.co.uk/?id=testpsw=testMsg=xxxxx .. ......

How can I send this request and manage the return code via FWH ?

Thanks in advance.

&&

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Re: Send an http request
Posted: Sun Apr 26, 2009 11:53 PM
Marco,

Marco Turco wrote:How can I send this request and manage the return code via FWH ?

if you want the user see the resulting page on your server, then you can use the IE ActiveX
http://forums.fivetechsupport.com/viewtopic.php?f=3&t=15058
otherwise you can use the TwebClient class to retrieve the page unattendently (\samples\webclien.prg)

Hi,
Davide
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Send an http request
Posted: Mon Apr 27, 2009 07:21 AM
I'm using the following function to run an URL, return the result page and eventually the error message. I don't know how to get the result code, though.

Code (fw): Select all Collapse
STATIC FUNCTION RUNURL( cUrl, cErr )

    LOCAL oUrl, oCli

    LOCAL lOk := .F.

    cErr = ""

    BEGIN SEQUENCE
        oUrl = TUrl():New( cUrl )

        IF EMPTY( oUrl ); BREAK; ENDIF

        oCli = TIPClientHttp():New( oUrl )

        IF EMPTY( oCli ); BREAK; ENDIF

        oCli:nConnTimeout = -1

        IF !oCli:Open(); BREAK; ENDIF

        cErr = CVALTOCHAR( oCli:ReadAll() )

        lOk = !EMPTY( oCli:cReply ) .AND. "OK" $ UPPER( oCli:cReply )

        oCli:Close()
    END SEQUENCE

    RETURN lOk


EMG
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Re: Send an http request
Posted: Mon Apr 27, 2009 12:15 PM
Enrico,
Enrico Maria Giordano wrote:I don't know how to get the result code, though.

I guess oCli:cReply will normally contain "200 OK"

Hi,
Davide
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Send an http request
Posted: Tue Apr 28, 2009 01:33 PM
Hi Marco,

Yo can review the post http://forums.fivetechsupport.com/viewtopic.php?f=3&t=12514&start=30. I think its similiar.

Regards,
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Send an http request
Posted: Tue Apr 28, 2009 04:09 PM
Hi Enrico,

your function could be fine but trying to link it I receive the following errors:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_HB_FUN_TURL' referenced from K:\TESTXBRW\OBJ\URL.OBJ
Error: Unresolved external '_HB_FUN_TIPCLIENTHTTP' referenced from K:\TESTXBRW\OBJ\URL.OBJ

Do I need to add any special libs ? I am using the last FWH/xHarbour release.

Thanks

Marco



Enrico Maria Giordano wrote:I'm using the following function to run an URL, return the result page and eventually the error message. I don't know how to get the result code, though.

Code (fw): Select all Collapse
STATIC FUNCTION RUNURL( cUrl, cErr )

    LOCAL oUrl, oCli

    LOCAL lOk := .F.

    cErr = ""

    BEGIN SEQUENCE
        oUrl = TUrl():New( cUrl )

        IF EMPTY( oUrl ); BREAK; ENDIF

        oCli = TIPClientHttp():New( oUrl )

        IF EMPTY( oCli ); BREAK; ENDIF

        oCli:nConnTimeout = -1

        IF !oCli:Open(); BREAK; ENDIF

        cErr = CVALTOCHAR( oCli:ReadAll() )

        lOk = !EMPTY( oCli:cReply ) .AND. "OK" $ UPPER( oCli:cReply )

        oCli:Close()
    END SEQUENCE

    RETURN lOk


EMG
Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Send an http request
Posted: Tue Apr 28, 2009 04:13 PM

Try to link tip.lib.

EMG

Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Send an http request
Posted: Tue Apr 28, 2009 05:40 PM

Solved. Thank you.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
Re: Send an http request
Posted: Thu Apr 30, 2009 06:11 AM

Ciao Enrico,

This the class TIP prepared for Harbour also ? Is this reliable one ? I thought that it was alone available for xHarbour. :roll:

Thanks.
C.

Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
HIX -> https://github.com/carles9000/hix
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Send an http request
Posted: Thu Apr 30, 2009 07:13 AM

Yes, it is called hbtip.lib in Harbour.

EMG

Continue the discussion