I included INet.h.
My code for http request is..
***************************************************************************************
HINTERNET hSession = ::InternetOpen("SomeName",
PRE_CONFIG_INTERNET_ACCESS,
NULL,
INTERNET_INVALID_PORT_NUMBER,
0) ;
HINTERNET hConnect = ::InternetConnect(hSession,
"http://localhost/login",
INTERNET_DEFAULT_HTTP_PORT,
user_id,
password,
INTERNET_SERVICE_HTTP,
0,
0) ;
SetLastError(0);
HINTERNET hHttpFile = ::HttpOpenRequest(hConnect,
"POST",
"",
HTTP_VERSION,
NULL,
0,
INTERNET_FLAG_DONT_CACHE,
0);
if(hHttpFile)
{
DWORD dwErr = GetLastError();
char message[1000];
sprintf(message, "Ya! Success! - Error = %u", dwErr);
MessageBox(NULL, message, "HttpOpenRequest", MB_OK);
}
else
{
DWORD dwErr = GetLastError();
char message[1000];
sprintf(message, "No! Failure! - Error = %u", dwErr);
MessageBox(NULL, message, "HttpOpenRequest", MB_OK);
}
INTERNET_BUFFERS inBuf;
inBuf.dwStructSize = sizeof(INTERNET_BUFFERS);
inBuf.Next = NULL;
inBuf.lpcszHeader = NULL;
inBuf.dwHeadersLength = 0;
inBuf.dwHeadersTotal = 0;
char postData[1000];
sprintf(postData, "user_id=%s&password=%s", user_id, password);
inBuf.lpvBuffer = postData;
inBuf.dwBufferLength = strlen(postData);
inBuf.dwBufferTotal = strlen(postData);
inBuf.dwOffsetLow = 0;
inBuf.dwOffsetHigh = 0;
INTERNET_BUFFERS outBuf;
outBuf.dwStructSize = sizeof(INTERNET_BUFFERS);
outBuf.Next = NULL;
outBuf.lpcszHeader = NULL;
outBuf.dwHeadersLength = 0;
outBuf.dwHeadersTotal = 0;
outBuf.lpvBuffer = new char[1000];
outBuf.dwBufferLength = 1000;
outBuf.dwBufferTotal = 1000;
outBuf.dwOffsetLow = 0;
outBuf.dwOffsetHigh = 0;
SetLastError(0);
BOOL bSendRequest = ::HttpSendRequestEx(hHttpFile, &inBuf, &outBuf,
HSR_SYNC, NULL);
if(bSendRequest)
{
DWORD dwErr = GetLastError();
char message[1000];
sprintf(message, "Ya! Success! - Error = %u", dwErr);
MessageBox(NULL, message, "HttpSendRequest", MB_OK);
}
else
{
DWORD dwErr = GetLastError();
char message[1000];
sprintf(message, "No! Failure! - Error = %u", dwErr);
MessageBox(NULL, message, "HttpSendRequest", MB_OK);
}
*****************************************************************************************************************
HttpOpenRequest works an return message is Ya! Success! Error = 122
HttpSendRequestEx goes in else and gives message No! Failure! Error = 87.
What is wrong with my code?
> HttpOpenRequest works an return message is Ya! Success! Error = 122
First, you have to understand, that if the function returns TRUE, there is
no need to look at error code - it does not have meaning.
> HttpSendRequestEx goes in else and gives message No! Failure! Error = 87.
I bet you got errors just because LPINTERNET_BUFFERS lpBuffersOut for
HttpSendRequestEx is reserved, and should be NULL. Also, you do not pass
correct url into InternetConnect. It should be withOUT http://.
I will attach a complete working source code in next message. You will be
able to download the source code if you use Outlook Express.
--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
"satishsuman" <satis...@discussions.microsoft.com> wrote in message
news:6F7D8AA9-4D18-45E2...@microsoft.com...
How to get it?
"Volodymyr M. Shcherbyna" wrote:
> Attached is the source code.
>
> --
> V.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> "Volodymyr M. Shcherbyna" <v_sch...@online.mvps.org> wrote in message
> news:O7IFEsMl...@TK2MSFTNGP02.phx.gbl...
--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
"satishsuman" <satis...@discussions.microsoft.com> wrote in message
news:A881FC25-A0D8-4732...@microsoft.com...
Much appreciated,
sascg
--
Volodymyr, blog: http://www.shcherbyna.com/
(This posting is provided "AS IS" with no warranties, and confers no
rights)
"sascg" <sa...@discussions.microsoft.com> wrote in message
news:403D3B0F-E9C2-4741...@microsoft.com...