| |
dhudson
Posts: 1
Score: 0
Joined: 7/29/2008
Status: offline
|
Hello all, Please excuse the possible ignorance of this question, but I am a bit of a VBScript newb. On to the post... I am trying to automate some reporting for my job. We have a ticketing system on our intranet that I have to pull reports from every hour. I am currently using M$ Excel's Web Query feature with a dynamic .iqy file. It auto imports the data every hour, then runs database functions on the resulting tables. What I would like to do is connect and login to the system using the XMLHTTP object, then send the variables for the report forms, store the resulting HTML in a string, and then my IT buddies can run SQL queries on the uploaded string. The issue... Here is my code: Option Explicit Dim objFSO, objNewFile Dim http, strCRS Dim strShowMyTasksQuery strShowMyTasksQuery = "func=ShowMyTasks" 'Create all the Objects Set http=CreateObject("Microsoft.XMLHTTP") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objNewFile = objFSO.CreateTextFile("H:\Scripts\CRS_Login.txt",True) 'Open and authenticate the connection http.open "GET","http://crs/index.php?",false, "username","password" 'Send the request for a response http.send strShowMyTasksQuery 'Store the resulting HTML response in a variable and write it to a text file strCRS = http.responseText WScript.Sleep 5000 objNewFile.Write(strCRS) 'Tidy up objNewFile.Close Set http=nothing Set objFSO = nothing Set objNewFile = nothing Now, the value of strShowMyTasksQuery is the resulting URL info from the get form when I run the report. So, the full URL of the report page is http://crs/index.php?func=ShowMyTasks. If I log into our ticketing system (named CRS if you have not guessed by now) through it's interface and just close it's windows without logging out and run this script it works fine. However, if I log out of the system through it's interface, the script logs me in, but does not run the report (even though I am sending the request to do so). All I get is the HTML for the CRS homepage, not the actual report. I know that the script is logging me in using the credentials specified in the .open parameter because when I bring up the page in my browser, I am logged in. I was wondering if it had to do something with giving the server enough time to authenticate my credentials, so I slept the script for a few seconds between the .open and the send. This yeilded the same result. I also did some digging and tried to set it up as an asynchronous request with an "onreadystatechange" thrown in. This did not work either. What I have noticed is that most of what I see online is utilizing a POST instead of a GET method. How do you know which one to use? I assume that if you can see your parameters in the URL on your browser, you need to use a GET. This does not seem to work for me though. I have tried POST, and got the same result. Any suggestions or advice would be greatly appreciated! Thanks.
|
|