Page 4 of 4
Posted: Wed Nov 26, 2008 12:13 am
by James Bott
Darrell,
I believe Antonio says that you have to use the ON INIT clause like this:'
ACTIVATE WINDOW oWnd2 ON INIT oActiveX:Do( "Navigate2", cConnect,,, GetPostData( cGetPost ), "Content-Type: application/x-www-form-urlencoded" + CRLF )
Regards,
James
Posted: Wed Nov 26, 2008 12:17 am
by Antonio Linares
Darrell,
Lets start with a first test. This should work fine:
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oWnd, oActiveX
DEFINE WINDOW oWnd
@ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer" OF oWnd
oWnd:oClient = oActiveX
ACTIVATE WINDOW oWnd ;
ON INIT oActiveX:Do( "Navigate2",;
"https://www.fivetechsoft.com/secure/english/test.php",,,;
GetPostData( "first=fivewin&last=FiveTech Software" ),;
"Content-Type: application/x-www-form-urlencoded" + CRLF )
return nil
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HRESULT hb_oleVariantToItem( PHB_ITEM pItem, VARIANT * pVariant );
HB_FUNC( GETPOSTDATA )
{
VARIANT vPostData = {0};
LPSAFEARRAY psa;
LPCTSTR cszPostData = hb_parc( 1 );
UINT cElems = lstrlen( cszPostData );
LPSTR pPostData;
VariantInit( &vPostData );
psa = SafeArrayCreateVector( VT_UI1, 0, cElems );
if( ! psa )
{
hb_retnl( E_OUTOFMEMORY );
return;
}
SafeArrayAccessData( psa, ( LPVOID * ) &pPostData );
memcpy( pPostData, cszPostData, cElems );
SafeArrayUnaccessData( psa );
V_VT( &vPostData ) = VT_ARRAY | VT_UI1;
V_ARRAY( &vPostData ) = psa;
hb_oleVariantToItem( hb_param( -1, HB_IT_ANY ), &vPostData );
}
#pragma ENDDUMP
Posted: Wed Nov 26, 2008 12:45 am
by cdmmaui
Antonio,
This produces the following output, is it correct?
This is a HTTPS post test. Please check your supplied data:
First: fivewin
Last: FiveTech Software
Posted: Wed Nov 26, 2008 1:04 am
by Antonio Linares
Darrell,
Yes, it is correct. Please notice that those values are the ones supplied here:
GetPostData( "first=fivewin&last=FiveTech Software" )
also, that we are using a HTTPS (secure) website.
Posted: Wed Nov 26, 2008 1:31 am
by cdmmaui
Hi Antonio,
I tried the following code with no success.
//----------------------------------------------------------------------------------
#include "FiveWin.ch"
function Main()
local oWnd, oActiveX, cGetPost := ''
cGetPost := '_nfpb=true&_nfls=false&_pageLabel=page_tracking3_trackSimple'
cGetPost += '&portlet_trackSimple_1wlw-select_key:{pageFlow.trackSimpleForm.type}OldValue=true'
cGetPost += '&portlet_trackSimple_1wlw-select_key:{pageFlow.trackSimpleForm.type}=CONTAINERNUMBER'
cGetPost += '&portlet_trackSimple_1{pageFlow.trackSimpleForm.numbers}=CLHU2068151'
DEFINE WINDOW oWnd
@ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer" OF oWnd
oWnd:oClient = oActiveX
ACTIVATE WINDOW oWnd ;
ON INIT oActiveX:Do( "Navigate2",;
"http://www.maerskline.com:80/appmanager/maerskline/public?_nfpb=true&portlet_quickentries_2_actionOverride=%2Fportlets%2Fquickentries%2FtrackCargo&_windowLabel=portlet_quickentries_2&_pageLabel=home",,,;
GetPostData( cGetPost ),;
"Content-Type: application/x-www-form-urlencoded" + CRLF )
return nil
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HRESULT hb_oleVariantToItem( PHB_ITEM pItem, VARIANT * pVariant );
HB_FUNC( GETPOSTDATA )
{
VARIANT vPostData = {0};
LPSAFEARRAY psa;
LPCTSTR cszPostData = hb_parc( 1 );
UINT cElems = lstrlen( cszPostData );
LPSTR pPostData;
VariantInit( &vPostData );
psa = SafeArrayCreateVector( VT_UI1, 0, cElems );
if( ! psa )
{
hb_retnl( E_OUTOFMEMORY );
return;
}
SafeArrayAccessData( psa, ( LPVOID * ) &pPostData );
memcpy( pPostData, cszPostData, cElems );
SafeArrayUnaccessData( psa );
V_VT( &vPostData ) = VT_ARRAY | VT_UI1;
V_ARRAY( &vPostData ) = psa;
hb_oleVariantToItem( hb_param( -1, HB_IT_ANY ), &vPostData );
}
#pragma ENDDUMP
Posted: Wed Nov 26, 2008 1:56 am
by Antonio Linares
Darrell,
Don't they provide a HTTPS url ?
I am going to bed now, we continue tomorrow

Posted: Wed Nov 26, 2008 2:27 am
by cdmmaui
Antonio,
They do not. I need to connect to about 50 or 60 websites and submit certain values and wait for the website to provide the information. Certain websites allow me to pass a string, for example
www.search.com?container=POLU1234567 and the website will display the details. However, many other websites do not allow this and I am performing a work around by copying container number to clipboard then opening website, then instructing user to PASTE container number in appropriate field then clicking submit button.
I hope a solution is possible.
Posted: Wed Nov 26, 2008 2:47 am
by cdmmaui
Antonio,
I am able to get the data to post and get results on other websites. Perhaps the Maersk website I gave is blocking this function???
Posted: Wed Nov 26, 2008 8:16 am
by Horizon
Darrell,
I think the problem is web site related. Both TIP class and ActiveX classes can post variables to web sites. Both examples are given before.