我正在用 C++ 开发一个程序,它与打开一个带有个人协议(protocol)(类似于 mailto 协议(protocol))的 URL 相关联。
我可以使用 argv[1]
恢复 GET 参数,但是 POST 参数是什么?
我读了this page但它是针对 CGI 程序的,而我的是客户端。
编辑:
@克里希纳努尼:
我也这么想,但我得到了这些结果。
使用 method="GET"
:
argv[0] = C:\Program Files\MySoftware\transferMail.exe
argv[1] = myproto:?to=&bcc=contact@test.com&subject=You%20are%20testing%20something%20new&attachment=&body=
并且使用 method="POST"
:
argv[0] = C:\Program Files\MySoftware\transferMail.exe
argv[1] = myproto:
我的循环不是很难:
for(int i=0; i < argc; ++i) {
cout << "argv[" << i << "] = " << argv[i] << endl;
}
最佳答案
只是给出我的解决方案:
我用 curl executable (版本 Win32 - 通用/Win32 2000/XP/二进制)用于下载包含我所有 POST 值的文件内容 。为了从我的程序中使用这个可执行文件,我使用了 popen()
函数。
这适用于带有 MinGW32 的 Windows Seven x64。
我不知道这是否是最好的解决方案,但效果很好!
关于c++ - 在 C++ 中获取使用 HTML 表单发送的 POST 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8487405/