#INCLUDE WCONNECT.h

SET PROCEDURE TO wwUtils ADDITIVE
SET PROCEDURE TO wwAPI ADDITIVE

SET PROCEDURE TO wwHTTP ADDITIVE
SET PROCEDURE TO wwFtp ADditive

CLEAR

SET MEMOWIDTH TO 200

*** For an SMTP Email Example please see wwSmtp_Sample.prg


*** Simple HTTP GET	
IF .F.
  loHttp = CREATEOBJECT("wwHttp")
  
  *** Get some HTML text from a URL
  lcHtml = loHttp.HTTPGet("http://www.west-wind.com/") 
  ShowText( lcHtml )  && show in text editor
  
  *** Download a binary file
  lcData=loHttp.HTTPGet("http://www.west-wind.com/files/foxreg.zip")

  * STRTOFILE(lcData,"foxreg.zip") && save binary data to a file on disk
  ? lcData
ENDIF  

*** HTTP POSTing data
IF .F.
	loHttp = CREATEOBJECT("wwHTTP")

    wait window nowait "Running HTTP request to get all A's from the detail list..."
	loHttp.AddPostKey("Client","B")
	loHttp.AddPostKey("FromDate","01/01/96")

    *** Preset the buffer and result size
	lcText=""
	lnText=0

	*** Send the POST data and retrieve HTTP result
	lcText = loHttp.HTTPGet("http://www.west0wind.com/wconnect/wc.dll?wwDemo~ShowHours")
	IF loHttp.nError # 0
	    ? loHttp.nError, loHttp.cErrorMsg
	    RETURN
	ENDIF
    ? lcText
ENDIF


	
*** FTP transfers	
IF .F.
    loIP=CREATE("wwFTP")
   
*    wait window nowait "Downloading pkzip to c:\temp"
	? loIP.FTPGetFile("ftp.west-wind.com","/wwipstuff.zip","c:\temp\wwipstuff.zip")

	*** Or you can use syntax like this:
	loIP.cFTPServer="ftp.west-wind.com"
	loIP.cFTPSource="c:\icsapilog.txt"
	loIP.cFTPTarget="/uploads/isapilog.txt"

	*** Use passwords if Anonymous is not allowed.
	* loIP.cUsername="username"      
	* loIP.cPassword="password"

    wait window nowait "Attempting to send file..."
	? loIP.FTPSendFile()
	if loIP.nError # 0
	   ? loIP.cErrorMsg
	   * ? loIP.GetLastInternetError(12003)
	endif

   ?
   ? "*** Listing files from: ftp.west-wind.com/*.*"
   loIP.FtpConnect("ftp.west-wind.com")
   	
   DIMENSiON laFiles[1]
   lnFiles = loIP.aFTPDir(@laFiles, "/*.*")  &&, lcUsername, lcPassword
   for x= 1 to lnFiles
      ? laFiles[x,1] + " Size: " + TRANSFORM(laFiles[x,2]) + " Timestamp: " + TRANSFORM(laFiles[x,4])
   ENDFOR
   
   *** Close connection
   loIP.FtpClose()
	
ENDIF

	
*** Domain Name Lookup
IF .F.
	*** Domain Lookups from IP Address and Reverse Domain Lookups
	? GetDomainFromIp("205.162.195.2")
	? GetIpFromDomain("www.microsoft.com")
ENDIF
