在向服务器发帖之前我需要添加任何标题吗?
例如,目前我正在尝试以这种方式发送请求以及发布数据,
LPCWSTR post = L"name=User&subject=Hi&message=Hi";
if (!(WinHttpSendRequest( hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
0, (LPVOID)post, wcslen(post),
wcslen(post), 0)))
{
//error
}
这应该行得通吗?
最佳答案
对我有用的:
LPSTR post = "log=test";//in my php file: if(isset($_POST['log']))
hRequest = WinHttpOpenRequest(hConnect,
L"POST",
L"/test.php",
NULL,
WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
0);
bResults = WinHttpSendRequest(hRequest,
L"content-type:application/x-www-form-urlencoded",
-1,
post,
strlen(post),
strlen(post),
NULL);
关于c++ - 使用 WinHttp 发布表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4530088/