http method get

http method get

Postby Marco Turco » Fri Nov 06, 2009 9: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: http method get

Postby alvaro533 » Fri Nov 06, 2009 9:29 am

See

viewtopic.php?f=6&t=17194

Regards,

Alvaro
alvaro533
 
Posts: 206
Joined: Sat Apr 19, 2008 10:28 pm
Location: Madrid, España

Re: http method get

Postby Marco Turco » 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:="GET http://condominio.emessage.it/CheckAgen ... Softwarexp HTTP/1.0"+CHR(13)+CHR(10)+"Host: http://condominio.emessage.it"+chr(13)+chr(10)

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

msginfo(cad)
return nil
Best Regards,

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

Re: http method get

Postby Enrico Maria Giordano » Fri Nov 06, 2009 10:52 am

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

Re: http method get

Postby anserkk » 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 *
Any specific lib to be linked ?

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: http method get

Postby anserkk » 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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: http method get

Postby Marco Turco » 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:=""

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

oCli:Close()
END SEQUENCE

RETURN lOk
Best Regards,

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 108 guests