Page 3 of 4
Posted: Thu Nov 20, 2008 2:52 pm
by Horizon
Hi
This is the another working example of posting datas using TIP class.
Code: Select all | Expand
#include "FiveWin.ch"
PROCEDURE Main
LOCAL oDlg
DEFINE DIALOG oDlg
@ 2,1 BUTTON oBtn PROMPT "Post Data to FiveTech" ACTION POST()
ACTIVATE DIALOG oDlg CENTERED
RETURN
PROCEDURE POST()
LOCAL oHttp, cHtml, hQuery, aLink, oNode, oDoc
oHttp:= TIpClientHttp():new( "http://www.fivetechsoft.com/secure/english/test.php" )
hQUery := Hash()
hSetCaseMatch( hQuery, .F. )
hQuery["first"] := "fivewin"
hQuery["last"] := "FiveTech Software"
// Connect to the HTTP server
IF .NOT. oHttp:open()
? "Connection error:", oHttp:lastErrorMessage()
QUIT
ENDIF
oHttp:Post(hQuery)
cHtml := oHttp:readAll()
oHttp:close()
oDoc := THtmlDocument():new( cHtml )
oDoc:writeFile( "download.html" )
msgInfo("Look at the download.html in this directory.")
RETURN
Posted: Sat Nov 22, 2008 5:39 pm
by cdmmaui
Hello,
I am trying to get this function to work with the following two websites. However, I cannot get data to post so web page displays information. I would appreaciate your help to resolve this problem.
Website #1:
Field Name = searchText
Field Value = NYKU7940156
http://www2.nykline.com/ct/containerSea ... ountry=USA
Website #2:
Field Name1 = portlet_trackSimple_1wlw-select_key:{pageFlow.trackSimpleForm.type}
Field Value1 = CONTAINERNUMBER
Field Name2 = portlet_trackSimple_1{pageFlow.trackSimpleForm.numbers}
Field Value2 = MAEU8279199
http://www.maerskline.com/appmanager/ma ... select_key:{actionForm.trackType}=CONTAINERNUMBER&portlet_quickentries_2{actionForm.trackNo}=MAEU8279199&_nfpb=true&_nfls=false&_pageLabel=page_tracking3_trackSimple
Posted: Sun Nov 23, 2008 12:27 pm
by Horizon
Hi Darrell,
First of all, I must say that I am also newby in FWH. The Guru's of FWH might answer your questions.
I think there are several reason for this:
1. "searchText" is wrong. 2. This web site is different than asp and php.
I have setup the test.asp in my web site like below.
Code: Select all | Expand
<html>
<body>
<%
search=request("searchText")
lang = request("lang")
country = request("country")
response.write "searchText = "
response.write search+"<br>"
response.write "lang = "
response.write lang+"<br>"
response.write "country = "
response.write country+"<br>"
%>
</body>
</html>
and changed the my test.prg like below.
Code: Select all | Expand
#include "FiveWin.ch"
PROCEDURE Main
LOCAL oDlg
DEFINE DIALOG oDlg
@ 2,1 BUTTON oBtn PROMPT "Post data to Web Site" ACTION POST()
ACTIVATE DIALOG oDlg CENTERED
RETURN
PROCEDURE POST()
LOCAL oHttp, cHtml, hQuery, aLink, oNode, oDoc
oHttp:= TIpClientHttp():new( "http://www.objekt.com.tr/fwh_test/test.asp?lang=en&country=USA" )
hQUery := Hash()
hSetCaseMatch( hQuery, .F. )
hQuery["searchText "] := "NYKU7940156"
// Connect to the HTTP server
IF .NOT. oHttp:open()
? "Connection error:", oHttp:lastErrorMessage()
QUIT
ENDIF
oHttp:Post(hQuery)
cHtml := oHttp:readAll()
oHttp:close()
oDoc := THtmlDocument():new( cHtml )
oDoc:writeFile( "download.html" )
msgInfo("Look at the download.html in this directory.")
RETURN
This is screen of the download.html created:
If post variable is wrong, You shuold find this from author of web site.
Posted: Sun Nov 23, 2008 5:44 pm
by cdmmaui
Thank You Horizon,
I am getting two unresolved external references.
_HB_FUN_TIPCLIENTHTTP
_HB_FUN_THTMLDOCUMENT
What library needs to be linked?
Thank You Again,
Posted: Sun Nov 23, 2008 5:51 pm
by cdmmaui
Horizon,
Sorry, I found tip.lib and program linked ok.
Posted: Mon Nov 24, 2008 2:27 pm
by cdmmaui
Antonio,
My current version of FWH is 8.07, do I need to upgrade to 8.10 in order to get this function to work.
Thank You,
Posted: Mon Nov 24, 2008 6:21 pm
by Horizon
Hi Darrell,
What is you exact problem?. Did you get an error ? or not compiled?. If you get an error, can you post it here?
Posted: Mon Nov 24, 2008 7:18 pm
by cdmmaui
Hi Horizon,
I tried to pull webpage using your source and changed web address, however I did not get a response, only the same page.
//----------------------------------------------------------------------------------
#include "FiveWin.ch"
PROCEDURE Main
LOCAL oDlg
DEFINE DIALOG oDlg
@ 2,1 BUTTON oBtn PROMPT "Post data to Web Site" ACTION POST()
ACTIVATE DIALOG oDlg CENTERED
RETURN
PROCEDURE POST()
LOCAL oHttp, cHtml, hQuery, aLink, oNode, oDoc
oHttp:= TIpClientHttp():new( "http://www2.nykline.com/ct/containerSearch.nyk;jsessionid=hvfzJpYPyGF5GndLySpZBh66pLp7SDv6FW1kqqHzq8yq1L9TQ9Wg!1248864524!-508217828?lang=en&country=USA" )
hQUery := Hash()
hSetCaseMatch( hQuery, .F. )
hQuery["searchText "] := "NYKU7940156"
// Connect to the HTTP server
IF .NOT. oHttp:open()
? "Connection error:", oHttp:lastErrorMessage()
QUIT
ENDIF
oHttp:Post(hQuery)
cHtml := oHttp:readAll()
oHttp:close()
oDoc := THtmlDocument():new( cHtml )
oDoc:writeFile( "download.html" )
msgInfo("Look at the download.html in this directory.")
RETURN
Posted: Tue Nov 25, 2008 7:58 am
by Horizon
Hi Darrell,
In order to check the FHW version conflict, I have compiled your test prg in XHB Builder and FWH 8.10. It seems no result.
TIP Class solution may not be solve your problem. You should try the activex solution.
Posted: Tue Nov 25, 2008 9:13 am
by Antonio Linares
I guess this is all that you need. It has been explained in this thread:
test.prg
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
Here you can download the EXE:
http://rapidshare.com/files/142522826/test.zip.html
Posted: Tue Nov 25, 2008 2:36 pm
by cdmmaui
Antonio,
Do I need to upgrade to FWH 8.10 for this to work? I currently have 8.07.
Posted: Tue Nov 25, 2008 2:48 pm
by Antonio Linares
Darrell,
Yes, I am afraid that you need FWH 8.10
It works nicely. Otto, Patrick, and others have tested it.
Posted: Tue Nov 25, 2008 3:58 pm
by cdmmaui
Hi Antonio,
No problem, I just purchased upgrade on-line, can you get me download as soon as possible?
Thank You!
Posted: Tue Nov 25, 2008 8:06 pm
by Antonio Linares
Dear Darrell,
We have just sent you an email about it.
Please let me know if you get it, thanks
Posted: Tue Nov 25, 2008 11:25 pm
by cdmmaui
Thank You Antonio,
I cannot the following code to work.
cConnect := 'http://www.maerskline.com/appmanager/maerskline/public'
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'
MENU oMenu
MENUITEM "&Close" ACTION ( oWnd2:End() )
ENDMENU
DEFINE WINDOW oWnd2 FROM 0, 0 TO 40, 85 MENU oMenu TITLE 'Tracking'
oActiveX = TActiveX():New( oWnd2, "Shell.Explorer" )
oWnd2:oClient = oActiveX
oActiveX:Do( "Navigate2", cConnect,,, GetPostData( cGetPost ), "Content-Type: application/x-www-form-urlencoded" + CRLF )
ACTIVATE WINDOW oWnd2 MAXIMIZED