Hello again, and thanks for the reply. I have been following your post and have come to a few problems. Just to make sure I had an understanding of your suggestions and the way the Yahoo login works, I tried to log in just by typing in all those form variables in the URL in my regular browser. I successfully logged in. So, I tried to apply that same principle to my program. I started off by calling InternetOpen:
Code:
if((hSession = InternetOpen("MFFS", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0)) == NULL){
printf("Could not connect.\n");
system("PAUSE");
return 0;
}
This seemed to work fine. I then called InternetConnect:
Code:
if((hDownload = InternetConnect(hSession, "login.yahoo.com", INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0)) == NULL){
printf("Couldn't reach site.\n");
system("PAUSE");
return 0;
}
I used the HTTPS port as you recommended. This also seemed to work fine. After that, I called HttpOpenRequest:
Code:
if((hRequest = HttpOpenRequest(hDownload, "POST", "https://login.yahoo.com/config/login?", NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0)) == NULL){
printf("Couldn't open request.\n");
system("PAUSE");
return 0;
}
I was a little unsure about this one. I used "https://login.yahoo.com/config/login?" because that's what it said on the form. I also used INTERNET_FLAG_SECURE because I know that Yahoo uses some sort of SSL certificate. Despite my uncertainties, this section also seemed to work fine. Finally, I tried to call HttpSendRequest:
Code:
if(!(HttpSendRequest(hRequest, NULL, 0, ".tries=1&.src=fpctx&.md5=%22%22&.hash=%22%22&.js=%22%22&.last=%22%22&promo=%22%22&.intl=%22us%22&.bypass=%22%22
&.partner=%22%22&.u=es8as592dk0vm&.v=0&.challenge=Cw8clMhTn1ljY2IIyNbBm3qXDP.X&.yplus=%22%22&.emailCode=%22%22
&pkg=%22%22&stepid=%22%22&.ev=%22%22&hasMsgr=0&.chkP=Y&.done=http://www.yahoo.com&.pd=fpctx_ver%3d0&login=(myusername)
&passwd=(mypassword)&.persistent=y", 401))){
DWORD errormsg = GetLastError();
printf("Couldn't send request.\n%i\n", errormsg);
system("PAUSE");
return 0;
}
This didn't work. First of all, I was unsure about the headers. I'm not sure what the headers are or if I really need them or not. So, I just used NULL for the headers and 0 for their size. Then I included the options, like you recommended. I used the ones that worked successfully in my browser, and for the size, just typed 401, which was the amount of characters it contained (Assuming that 1 char = 1 byte). However, this didn't work, so I tried to use GetLastError. The code it returned was 12031. I looked this up and found:
Code:
ERROR_INTERNET_CONNECTION_RESET
12031
The connection with the server has been reset.
Hmm... Not quite sure what that means, or why it happened. So anyway, my questions are:
- What are the headers in HttpSendRequest, and do I need them?
- What is ERROR_INTERNET_CONNECTION_RESET trying to tell me?
- And I haven't quite gotten to this point yet, but I believe that once I log in, Yahoo sends my browser a few cookies so that other pages recognize that I am logged in. My question is, how do I get my program to retrieve these cookies and present them to the page I am trying to access so that it recognizes that I am logged on?
Thanks a lot, Joe.