FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour http method get
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
http method get
Posted: Fri Nov 06, 2009 09:15 AM

Hi all,
I need to execute an http string like this:

http://condominio.emessage.it/CheckAgen ... word=pluto

and obtain the result html code.

How can I make this ?

Thanks in advance

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 230
Joined: Sat Apr 19, 2008 10:28 PM
Re: http method get
Posted: Fri Nov 06, 2009 09:29 AM

See

viewtopic.php?f=6t=17194

Regards,

Alvaro

&

Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: http method get
Posted: Fri Nov 06, 2009 10:11 AM

Hi, thank for your suggest.
I tried but always return nil.
Did I make something wrong ?

include "FiveWin.ch"

static oWnd

//----------------------------------------------------------------------------//

function Main()

local oBar

DEFINE WINDOW oWnd TITLE "WebClient test"

DEFINE BUTTONBAR oBar 3D OF oWnd
DEFINE BUTTON OF oBar ACTION WebClient()

ACTIVATE WINDOW oWnd

return nil

function WebClient()
local oWebClient,cad, cstring

cString:=&quot;GET <!-- m --><a class="postlink" href="http://condominio.emessage.it/CheckAgent.aspx?Userid=pippo&amp;Password=pluto&amp;Agente=Softwarexp">http://condominio.emessage.it/CheckAgen ... Softwarexp</a><!-- m --> HTTP/1.0&quot;+CHR(13)+CHR(10)+&quot;Host: <!-- m --><a class="postlink" href="http://condominio.emessage.it">http://condominio.emessage.it</a><!-- m -->&quot;+chr(13)+chr(10)

oWebClient := TWebClient():New()
oWebClient:Connect( &quot;condominio.emessage.it&quot; )
oWebClient:bOnRead    = { | cData | cad+=cData }
oWebClient:oSocket:SendData( cString)

msginfo(cad)

return nil

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: http method get
Posted: Fri Nov 06, 2009 10:52 AM
Code (fw): Select all Collapse
FUNCTION MAIN()

    ? GETURL( "http://condominio.emessage.it/CheckAgent.aspx?Userid=pippo&Password=pluto" )

    RETURN NIL


FUNCTION GETURL( cUrl )

    LOCAL cFile := SUBSTR( cUrl, RAT( "/", cUrl ) + 1 )

    LOCAL oUrl, oCli

    LOCAL lOk := .F.

    IF "?" $ cFile
        cFile = LEFT( cFile, RAT( "?", cFile ) - 1 )
    ENDIF

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

        IF EMPTY( oUrl ); BREAK; ENDIF

        oCli = TIPClientHttp():New( oUrl )

        IF EMPTY( oCli ); BREAK; ENDIF

        IF !oCli:Open(); BREAK; ENDIF

        IF !oCli:ReadToFile( cFile ); BREAK; ENDIF

        lOk = "OK" $ UPPER( oCli:cReply )

        oCli:Close()

        IF !lOk; FERASE( cFile ); ENDIF
    END SEQUENCE

    RETURN lOk


EMG
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: http method get
Posted: Fri Nov 06, 2009 11:41 AM
Dear Mr.EMG,

    Error: Unresolved external '_HB_FUN_TURL' referenced from D:\HTTPGET.OBJ
    Error: Unresolved external '_HB_FUN_TIPCLIENTHTTP' referenced from D:\HTTPGET.OBJ
    * Linking errors *
    [/list:u]
    Any specific lib to be linked ?

    Regards
    Anser
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: http method get
Posted: Fri Nov 06, 2009 11:50 AM
Sorry, got the answer from here
http://forums.fivetechsupport.com/viewtopic.php?f=3&t=15409
Tip.Lib

Regards
Anser
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: http method get
Posted: Fri Nov 06, 2009 12:10 PM

Ok, solved :D
Thanks all for the support

FUNCTION RUNURL( cUrl, cErr ,cDataToCheck)

LOCAL oUrl, oCli

LOCAL lOk := .F.
LOCAL CRETURN:=&quot;&quot;

cErr = &quot;&quot;

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() )
    if cDataToCheck&lt;&gt;NIL
        if at(cDataToCheck,cErr)&gt;0
            lOk:=.t.
        endif
    else
        lOk = !EMPTY( oCli:cReply ) .AND. &quot;OK&quot; $ UPPER( oCli:cReply )
    endif
    cReturn:=oCli:cReply()

    oCli:Close()
END SEQUENCE

RETURN lOk
Best Regards,



Marco Turco

SOFTWARE XP LLP

Continue the discussion