Click here to Skip to main content
15,912,493 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalsocket state Pin
dmiv27-May-03 3:33
dmiv27-May-03 3:33 
GeneralRe: socket state Pin
valikac27-May-03 6:22
valikac27-May-03 6:22 
GeneralRe: socket state Pin
dmiv27-May-03 20:39
dmiv27-May-03 20:39 
GeneralRe: socket state Pin
valikac28-May-03 5:04
valikac28-May-03 5:04 
GeneralGet Thread Handle below WinMe Pin
Ceri27-May-03 3:32
Ceri27-May-03 3:32 
GeneralRe: Get Thread Handle below WinMe Pin
Peter Weyzen27-May-03 7:40
Peter Weyzen27-May-03 7:40 
GeneralRe: Get Thread Handle below WinMe Pin
Ceri27-May-03 21:38
Ceri27-May-03 21:38 
GeneralGet data from a password protected webpage Pin
NorbertBehrens27-May-03 3:27
NorbertBehrens27-May-03 3:27 
Hi,

I try to get data from a password protected webpage and need a little help.

At first I want to describe the situation in the browser.
When I call the webpage, I got a page with a little login screen. This is realized by some javascript code. I fill in the username and password, click on 'login' and voila, there are my wanted data.

I looked at the javascript code an noticed the names of the fields. I tried to call the webpage directly with:

http://<address>?<NameOfUserField>=<username>&<NameOfPasswordField>=<password>&action=<actionname>

... and it works fine. Now I had to do the same in my MFC-Projekt but I failed. I was unsuccessful with the following two attempts

#################
## First Attempt
#################
********************************************************************************************************
...
CInternetsession InternetSession(_T("AppName"),1, INTERNET_OPEN_TYPE_PRECONFIG);
char Url = "<address>?<NameOfUserField>=<username>&<NameOfPasswordField>=<password>&action=<actionname>";
CString strServerName; // Server
CString strObject; // directory
INTERNET_PORT nPort; // port
DWORD dwServiceType; // accesstype
AfxParseURL(Url, dwServiceType, strServerName, strObject, nPort)
DWORD dwHttpRequestFlags = INTERNET_FLAG_RELOAD;
CHttpFile *pHttpFile = pHttpConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET,// or HTTP_VERB_POST
strObject, NULL, 1, NULL, NULL,
dwHttpRequestFlags);
pHttpFile->SendRequest();
CString sz;
while (pHttpFile->ReadString(sz)){
...
}
********************************************************************************************************
#################
## Second Attempt
#################
...
CInternetsession InternetSession(_T("AppName"),1, INTERNET_OPEN_TYPE_PRECONFIG);
char Url = "<Only_Address_without_parameter>";
CString strServerName; // Server
CString strObject; // directory
INTERNET_PORT nPort; // port
DWORD dwServiceType; // accesstype
AfxParseURL(Url, dwServiceType, strServerName, strObject, nPort)
DWORD dwHttpRequestFlags = INTERNET_FLAG_RELOAD;
CHttpFile *pHttpFile = pHttpConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET,// or HTTP_VERB_POST
strObject, NULL, 1, NULL, NULL,
dwHttpRequestFlags);
CString szHeader = _T("<NameOfUserField>=<username>&<NameOfPasswordField>=<password>&action=<actionname>");
pHttpFile->AddRequestHeaders(szHeader);
pHttpFile->SendRequest();

CString sz;
while (pHttpFile->ReadString(sz)){
...
}
********************************************************************************************************

Any Idea's?

ciao
Norbert
GeneralWriting CString to file - problems Pin
Berkut27-May-03 3:11
Berkut27-May-03 3:11 
GeneralRe: Writing CString to file - problems Pin
David Crow27-May-03 3:16
David Crow27-May-03 3:16 
GeneralRe: Writing CString to file - problems Pin
John M. Drescher27-May-03 3:23
John M. Drescher27-May-03 3:23 
GeneralRe: Writing CString to file - problems Pin
Peter Weyzen27-May-03 8:00
Peter Weyzen27-May-03 8:00 
GeneralOfficeXP-like Menus Pin
Xakep27-May-03 3:01
Xakep27-May-03 3:01 
GeneralRe: OfficeXP-like Menus Pin
John R. Shaw27-May-03 5:35
John R. Shaw27-May-03 5:35 
Generalinserting records with ado Pin
si_6927-May-03 2:45
si_6927-May-03 2:45 
GeneralRe: inserting records with ado Pin
John M. Drescher27-May-03 4:42
John M. Drescher27-May-03 4:42 
GeneralRe: inserting records with ado Pin
si_6927-May-03 4:58
si_6927-May-03 4:58 
GeneralRe: inserting records with ado Pin
John M. Drescher27-May-03 5:10
John M. Drescher27-May-03 5:10 
GeneralRe: inserting records with ado Pin
si_6927-May-03 5:19
si_6927-May-03 5:19 
GeneralRe: inserting records with ado Pin
John M. Drescher27-May-03 5:28
John M. Drescher27-May-03 5:28 
GeneralExplorer Bar Question Pin
YuHao27-May-03 2:39
YuHao27-May-03 2:39 
GeneralRe: Explorer Bar Question Pin
Rage27-May-03 5:49
professionalRage27-May-03 5:49 
GeneralRe: Explorer Bar Question Pin
YuHao27-May-03 19:22
YuHao27-May-03 19:22 
GeneralVC6 add in: print to Build output window Pin
peterchen27-May-03 1:45
peterchen27-May-03 1:45 
GeneralMDI with multiple views and one document Pin
Andy@27-May-03 1:43
Andy@27-May-03 1:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.