How to check the status of a url, with credentials

Post Reply
FWExplorer
Posts: 83
Joined: Fri Aug 09, 2013 12:43 am

How to check the status of a url, with credentials

Post by FWExplorer »

Hi,

I wrote a python utility earlier in the year that checks connectivity, and optionally html file size, and optionally with credentials.

Are there some FW snippets that will accomplish the same thing? I already tried searching through Minigui and played with TIpClientHttp, and cannot find anything in the fwh distribution.

Some of the sites I'm checking are https ; some are http.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: How to check the status of a url, with credentials

Post by Antonio Linares »

This works without credentials:

function WebPageContents( cUrl, lText ) --> cContents

For credentials we have to use:

user = "someusername"
password = "somepassword"
xmlhttp.setRequestHeader "Authorization", "Basic " + Base64Encode(user + ":" + password)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: How to check the status of a url, with credentials

Post by Antonio Linares »

Here you have a working example with credentials:

http://forums.fivetechsupport.com/viewt ... 92#p234092
regards, saludos

Antonio Linares
www.fivetechsoft.com
FWExplorer
Posts: 83
Joined: Fri Aug 09, 2013 12:43 am

Re: How to check the status of a url, with credentials

Post by FWExplorer »

Thanks, Antonio.
Antonio Linares wrote:This works without credentials:

function WebPageContents( cUrl, lText ) --> cContents

For credentials we have to use:

user = "someusername"
password = "somepassword"
xmlhttp.setRequestHeader "Authorization", "Basic " + Base64Encode(user + ":" + password)
FWExplorer
Posts: 83
Joined: Fri Aug 09, 2013 12:43 am

Re: How to check the status of a url, with credentials

Post by FWExplorer »

What option do we need, on the Buildh command line to include the FW Ole functions?

I put PingValidate.prg, containing WebPageContents() in the samples folder. But we have some missing externals.

Which library has olefuncs.prg already linked in?


Error: Unresolved external '_HB_FUN_FWGETOLEOBJECT' referenced from C:\FWH\SAMPLES\PINGVALIDATE.OBJ
Error: Unresolved external '_HB_FUN_FW_GT' referenced from C:\FWH\SAMPLES\PINGVALIDATE.OBJ
Error: Unable to perform link
* Linking errors *


Code: Select all

#include "fivewin.ch"

function WebPageContents( cUrl, lText )

   local oHttp, cContents := ""
   local nOle  := 0
   local aOle  := { "MSXML2.XMLHTTP", "WINHTTP.WinHttpRequest.5.1" }

   if Lower( Left( cUrl, 7 ) ) == "http://" .or. Lower( Left( cUrl, 8 ) ) == "https://"

      do while Empty( cContents ) .and. nOle < 2
         nOle++
         TRY
            oHttp     := FWGetOleObject( aOle[ nOle ] )
            oHttp:Open("GET", cUrl, .f. )
            oHttp:Send()
            DEFAULT lText := .f.
            if lText
               cContents   := oHttp:ResponseText()
            else
               cContents   := oHttp:ResponseBody()
            endif
         CATCH
         END
      enddo
   endif

return cContents

//----------------------------------------------------------------------------//

 
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: How to check the status of a url, with credentials

Post by Antonio Linares »

D.

> Which library has olefuncs.prg already linked in?

FiveH.lib
regards, saludos

Antonio Linares
www.fivetechsoft.com
FWExplorer
Posts: 83
Joined: Fri Aug 09, 2013 12:43 am

Re: How to check the status of a url, with credentials

Post by FWExplorer »

Never mind. I typed build.bat, rather than buildh.bat. Everything's good.
Post Reply