Dear friends, I need to send an https POST (data and headers) using xHarbour/FWH. Any ideas?
EMG
oExp:Document:Body:InnerText
Error InternetExplorer.Application:DOCUMENT/0 S_OK: BODY
cSAY := "Gathering product information "
oSay:ReFresh()
SysReFresh()
try
cTEXT := lower(IE1:document:documentElement:outerTEXT)
catch
cSAY := "Can not open Product information "+cPARTS
oSay:ReFresh()
SysReFresh()
try
IE1:Quit()
catch
end try
IE1 := NIL
SysReFresh()
return(.f.)
end try
SysWait( 3)
// take out all the control char
nLOOP := 0
DO WHILE .T.
IF AT( (chr(13)+chr(10)), cTEXT ) > 0
cTEXT := STRTRAN( cTEXT, (chr(13)+chr(10)), space(1) )
ENDIF
nLOOP++
IF nLOOP > 500
EXIT
ENDIF
ENDDO
* msginfo( ctext )
// cSubmit_Login_button := "document:forms:login:login" // actual DOM address
try
* bSUBMIT := &( [ { | IE | IE:]+cSUBMIT_LOGIN_BUTTON_DOM+[:Click()]+[ }] )
OSendMulti( IE, cSUBMIT_LOGIN_DOM+":Click", ) // in func_lib.prg
catch
cSAY := "Clicking Login button FAILED"
oSay:ReFresh()
SysReFresh()
aLINE := { cURL,cPARTS,cSAY," ", " ", " " }
AAdd( aResults, aLine )
oLbx2:Refresh()
oLbx2:GoBottom()
try
IE:Quit()
catch
end try
IF cTESTING = "TEST"
oBtn1:Enable()
oBtn2:Enable()
ENDIF
SysReFresh()
RETURN(.F.)
end try
//------------------------------
// this function takes a method string
// and evals it instead of creating a complex
// code block
//
// OSendMulti( IE,"document:forms:tsf:lst-ib:Value", cPARTS )
//
//-----------------------------------------
Function OSendMulti( o, cMsg, uVal )
local aMsg := HB_ATokens( cMsg, ":" )
local n := Len( aMsg ) - If( uVal == nil, 0, 1 )
local p
AEval( aMsg, { |c| o := OSendEx( o, c ) }, 1, n )
if uVal != nil
o := OSend( o, "_" + ATail( aMsg ), uVal )
endif
return( o )
//--------------------------------------------------------------------------------------------------//
#include "FiveWin.ch"
//--------------------------------------------------------------------------------------------------//
Function Main()
MsgInfo( SendPostToUrl( "http://localhost/test.php", "name=lailton&country=brazil" ), "POST" )
Return Nil
//--------------------------------------------------------------------------------------------------//
Function SendPostToUrl( cUrl, cParams )
Local oOle,cRet:='',uRet
Try
oOle := CreateObject( 'MSXML2.XMLHTTP' )
Catch
oOle := CreateObject( 'Microsoft.XMLHTTP' )
End
oOle:Open( 'POST', cUrl, .f. )
oOle:SetRequestHeader( "Content-Type", "application/x-www-form-urlencoded" )
oOle:Send( cParams )
SysRefresh()
#ifdef __XHARBOUR__
cRet := oOle:ResponseBody
#else
AEval(oOle:ResponseBody,{|uRet|cRet+=Chr(uRet)})
#endif
Return cRet
//--------------------------------------------------------------------------------------------------//
<?php
if($_POST){
echo "Yes Post :-)\n\n";
print_r( $_POST );
}else{
echo "Not Post :-(";
}
?>
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 111 guests