Solved

Use HttpRequest to login to a website remotely, like Gmail, Hotmail, etc

Posted on 2007-12-05
6
1,514 Views
Last Modified: 2010-04-21
I need to be able to login to a website remotely.  By remotely, I mean, within my code, I send a request with the login information to the url designated within my code and the remote website receives the username/password information (and any cookies if necessary, but I'm not sure how to detect the cookies if they are needed).  The remote website will receive the username/password information as if I had typed them into the input fields and hit the form submit button.  The response to sending the request remotely should be whatever page would be shown after the user logs in.  I have seen many people say that this is not even possible, or is a security risk, but that's not the case at all.  

If you look at this URL:  http://www.netomatix.com/development/httpwebrequestredirect.aspx  then you will see that it is definitely possible.  This programmer has done something like it in the past, I just can't find code.  One draw back is that I do not know ASP.NET, but am working on learning it.  I've programmed in classic ASP and PHP for 7 years.  The website, upon logging in, may send cookies that I will need to detect and send back with any future requests.

This question is worth 500 points and much admiration if you can help me out with this.  I apologize for needing very specific examples and/or working code.  I have a webserver online that I can upload files to directly and see if it works.  Thanks in advance for your help.

Jarod
0
Comment
Question by:jallenmorris
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 19

Expert Comment

by:v2Media
ID: 20417011
It's not done with asp.net, it's done with ajax. Regardless, you'll need to also write the server-side scripts that the ajax call connects to. So if you don't know asp.net, do you know php and mysql databases?
0
 

Author Comment

by:jallenmorris
ID: 20417060
I know what AJAX is, and this is not like AJAX.  This is not using javascript.  You can use ASP.NET to do this, which is why Microsoft included HttpWebRequest with ASP.NET.  I know PHP and MySQL and Classic ASP very well.

v2Media,

Did you even bother going to the url that I pasted in the original post?  HttpRequest sends the request and brings back the response before anything is ever sent to the browser.  It's a very useful tool and acts in a very different way than AJAX.  I've written custom AJAX applications in for other websties, but none of them required me to login to a separate website.

If you notice in the code snippet I have provided, that function uses HttpRequest to send a request to a webpage and return the response from the server, all without AJAX and all before the page is loaded.
function get_it(theURL)
	Dim HttpRequest, myImage, Status
	Set HttpRequest = Server.CreateObject("MSXML2.XMLHTTP.3.0")
	HttpRequest.Open "POST", theURL, false
	HttpRequest.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
	HttpRequest.Send "txtPassword=myPasswordHere&txtUserName=myUserNameHere"
	'use this next comment line to know how to send form data
	Status = HttpRequest.responseText
	Get_It = Status
End Function
 
dim first, second, third
first = get_it("https://www.claimintelligence.com/CIApp/UserLoginUI.aspx")
second = get_it("https://www.claimintelligence.com/CIApp/ModuleMainMenu.aspx")
 
dim find
'ThisTitleStart = InStr(Items(a),"<title>")+16
 
response.write second

Open in new window

0
 
LVL 19

Accepted Solution

by:
v2Media earned 500 total points
ID: 20417227
I did read it and I did look at the webpage. However I thought I prod into why you would want to adopt a new platform just to get content from an external website... As I said, it's usually done with ajax, however I now assume you're talking about a remote site that you can't upload scripts to yes?

Why bother with a new platform just for a login script when you can already do the same job with existing skills? It can also be done with php curl...

This looks to fit the bill:

http://php.assistprogramming.com/php-logindownload-file-curl-libraries.html
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:jallenmorris
ID: 20417330
v2Media,

Thanks for that url.  I think that might be what I was looking for.  One thing I love about programming is that there is almost always more than one way to solve a problem.  I don't really need to download content from a website.  The use for this is rather different than most uses.  For my work, I use a web-based ASP.NET website created specifically for my company.  The problem is that we've contracted out the development so the programmers are very, very, very unresponsive to what we would like to have the web-based application do.  Essentially, it's a series of forms, but over about 30 pages that we use.  There are about 5 separate pages we use approximately 80% of the time.  I want to be able to login, and then parse the information on the page to create my own forms and then process the information.  Basically create my own GUI for the web-based application.  My supervisor has encouraged me to look into it because of my programming background since we can't get the contractor to modify the application.  For example, we have a certain task that we do, such as select an item that we need to modify or adjust.  We check a checkbox, then have to scroll down the page to hit the submit button, which takes us to another page.  We have standard language that we post into another form according to what adjustment needs to be made to the invoice/bill we are reviewing.  We get that standard language from an XLS file that each user has.  We copy and paste that standard language into the web application, then hit submit.  That saves the information and then we have to hit another button to go back to the page where we can select another item that must be modified.  In all, it is about 6 - 8 clicks for each task that we do.  If I can login and recreate my own GUI, then I can incorporate the information from the XLS into my custom GUI and eliminate many of the clicks that we are not using.  It may sound odd, but if you eleiminate even 5 - 10 seconds per item modified or adjusted, over an entire day/week/month, etc that really improves productivity.  Thanks for your help.  You get the points.
0
 

Author Closing Comment

by:jallenmorris
ID: 31413041
Thanks for your help.
0
 

Author Comment

by:jallenmorris
ID: 20462490
To anyone that may check this page as an answer for a question regarding the same thing.  I have gotten my script to work using cURL.  The site I'm using this on does send cookies, it also has VIEWSTATE with ASP.NET .aspx and it's working good so far.  If you want help with what you're working on, just send me an email.  jarod dot morris at gmail dot com.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question