Hi,
I am trying post some data to one php server that accept data by "POST" method.
I am using below standard code that I found in MSDN.
My server address is: www.arad.com//up/up.php
Data want Post is: "/MT4i TradeCopy Sender MT4iTradeCopy 2013-10-11"
And my code is:
#include "StdAfx.h"
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include "winhttp.h"
#pragma comment (lib,"Winhttp.lib")
int main(int argc, char *argv[])
{
LPCWSTR server=L"www.arad.com";
LPCWSTR ext=L"/up/up.php";
LPCWSTR data=L"/MT4i TradeCopy Sender MT4iTradeCopy 2013-10-11";
BOOL bResults = FALSE;
HINTERNET hSession = NULL,
hConnect = NULL,
hRequest = NULL;
hSession = WinHttpOpen( L"A WinHTTP Example Program/1.0",
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0);
if (hSession)
hConnect = WinHttpConnect( hSession, server,
INTERNET_DEFAULT_HTTP_PORT, 0);
if (hConnect)
hRequest = WinHttpOpenRequest( hConnect, L"POST",
0,
ext, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
0);
if (hRequest)
bResults = WinHttpSendRequest( hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
0, (LPVOID)data, wcslen(data),
wcslen(data), 0);
if (!bResults)
printf( "Error %d has occurred.\n", GetLastError());
if (hRequest) WinHttpCloseHandle(hRequest);
if (hConnect) WinHttpCloseHandle(hConnect);
if (hSession) WinHttpCloseHandle(hSession);
return 0;
}
But hen try POST, it send nothing to server. How can I fix that?
Another question:
What is max length for data that can Post to server?
Regards,