hi Edward,
thx for Answer.
i have "read" what you say ... but i´m a Internet "Dummy" so i do not understand how to use it
i use this CODE to download Message from phpBB Forum
cURL :=
https://www.hmgforum.com/viewtopic.php?t=
cFile := any Filename to hold Message
nThreadNo := 7451
Code: Select all
FUNCTION DownloadFromWWW( cURL, cFile, nThreadNo )
LOCAL oError, nTry, nStatus, nReadystate, cText, nPosi
LOCAL bOldError := ERRORBLOCK( { | e | BREAK( e ) } )
LOCAL oHttp := Win_OleCreateObject( "MSXML2.ServerXMLHTTP" )
LOCAL aStatus := HttpStatusArray()
LOCAL aArray, x1
IF FILE( cFile )
hb_FileDelete( cFile )
ENDIF
IF .NOT. "http" $ cUrl
oHttp := NIL
RETURN .F.
ENDIF
BEGIN SEQUENCE // WITH { | oError | BREAK( oError ) }
oHttp:Open( "GET", cUrl, .F. )
// oHttp:setRequestHeader( "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" )
oHttp:setRequestHeader( "Content-Type", "text/xml; charset=utf-8" )
nTry := 0
DO WHILE EMPTY( oHTTP:readyState ) // = 0
nTry ++
millisec( 500 )
DO Events
IF nTry > 5
BREAK
ENDIF
ENDDO
// oHttp:setRequestHeader( "Content-Type", "text/xml; charset=utf-8")
oHttp:Send()
nReadystate := oHttp:readyState
IF nReadystate <> 4
BREAK
ENDIF
nStatus := oHttp:Status
IF nStatus = 200
StrFile( oHttp:ResponseBody(), cFile )
x1 := hb_jsonDecode( oHttp:ResponseBody(), @aArray )
ELSEIF nStatus = 500
lBreak := .T.
cText := "Error Thread No. : " + VAR2CHAR( nThreadNo ) + CRLF + cText
MessageBoxTimeout( cText, "nStatus = " + VAR2CHAR( nStatus ), MB_ICONERROR, 3000 )
lShowOnce := .F.
BREAK
ELSE
Ondummy( oHttp:Status )
nPosi := ASCAN( aStatus, { | x | x[ 1 ] = nStatus } )
IF nPosi > 0
cText := aStatus[ nPosi ] [ 2 ]
Ondummy( TIME(), cText )
// lBreak := .T.
// lShowOnce := .T.
// BREAK
ENDIF
ENDIF
RECOVER USING oError
ERRORBLOCK( bOldError )
IF EMPTY( nReadystate )
ELSE
lBreak := .T.
lShowOnce := .T.
ENDIF
Ondummy( TIME(), oError:description, oError:operation, HB_VALTOSTR( oError:osCode ), "Error download " + cUrl )
cText := hb_Translate( oError:Description, cTranslateCP + "WIN" )
SayBarText( cText, "ICOERROR" )
IF lBreak = .F.
cText := "Error Thread No. : " + VAR2CHAR( nThreadNo ) + CRLF + cText
MessageBoxTimeout( cText, "readyState " + VAR2CHAR( nReadystate ), MB_ICONERROR, 3000 )
lShowOnce := .F.
ENDIF
IF lShowOnce = .T.
lShowOnce := .F.
MsgStop( "Error : " + cText, "readyState " + VAR2CHAR( nReadystate ) )
ENDIF
AADD( aError, { "Error Thread No. : " + VAR2CHAR( nThreadNo ), RECNO() } )
END SEQUENCE
ERRORBLOCK( bOldError )
oHttp:Abort()
oHttp := NIL
RETURN FILE( cFile )
i do NOT "login" yet so i can read only Public Message
i need to "login" to get Cookie / Session-ID which than is "add" ( sid= ) to URL String
Code: Select all
https://www.xbaseforum.de/search.php?search_id=active_topics&sid=f4f5f06a9330b2dc3ab692a5a6a597b5
so i need some "login" CODE before DownloadFromWWW() ... but how
