Send an http request

Send an http request

Postby Marco Turco » Sun Apr 26, 2009 4:22 pm

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

http://softwarexp.co.uk/?id=test&psw=test&Msg=xxxxx .. ......

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

Thanks in advance.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Send an http request

Postby Davide » 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
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Re: Send an http request

Postby Enrico Maria Giordano » Mon Apr 27, 2009 7: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: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Send an http request

Postby Davide » 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
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy


Re: Send an http request

Postby Horizon » Tue Apr 28, 2009 1: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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Send an http request

Postby Marco Turco » Tue Apr 28, 2009 4: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: Select all  Expand view
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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London


Re: Send an http request

Postby Marco Turco » Tue Apr 28, 2009 5:40 pm

Solved. Thank you.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Send an http request

Postby Carles » Thu Apr 30, 2009 6: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
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1134
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Send an http request

Postby Enrico Maria Giordano » Thu Apr 30, 2009 7:13 am

Yes, it is called hbtip.lib in Harbour.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 99 guests