使用HTTP请求时,LIBCPR无法正常工作
我正在使用LIBCPR进行HTTP请求,以示为Visual Studio 2019 IDE。我使用Microsoft使用VCPKG下载了它。下面的示例代码来自CPR GITHUB页面 https://github.com/libcpr/cpr#:~: text=%23include%20%20%20%3c,ereturn%200%3B%0A%7D
#include <cpr/cpr.h>
int main(int argc, char** argv) {
cpr::Response r =
cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"},
cpr::Authentication{"user", "pass", cpr::AuthMode::BASIC},
cpr::Parameters{{"anon", "true"}, {"key", "value"}});
r.status_code; // 200
r.header["content-type"]; // application/json; charset=utf-8
r.text; // JSON text string
return 0;
}}
这不起作用!它给出错误“命名空间” CPR没有成员“ authmode”。此问题不仅如此。还有其他一些东西给出类似的错误,例如-usage.html#https-options:%7E:文本= CPR%3A%3Assloptions%20SSLOPTS%20%3D%20CPR%3A%3A%3ASSL(SSL%3A%3A%3A%3AACABUFFER%7B%7B%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D% 2DBegin%20certificate%2D%2D%2D%2D%2D%5B ...%5D%22%7D)%3B%0ACPR%3A%3A%3ARESPONSE%20R%20R%20%20%3D%20CPR%20cpr%3A%3A%3AGET(CPR%3A%3A%) 3Aurl%7B%22HTTPS%3A // www.httpbin.org/get%22%7D%2C%20SSlopts)%3B“ rel =“ nofollow noreferrer”> https://docs.libcs.libcpr.org/advanced-cr.orgagecad-angachanc--usage-usage.htmll..html #https-options:〜:text = cpr%3A%3Assloptions%20SSlopts%20%3D%20CPR%3A%3ASSL(SSL%3A%3A%3AACABUFFER%7B%7B%22%2D%2D%2D%2D%2D%2D%2D%2D%2DBEGGIN%20certicate%20certicate%20%2D %2D%2D%2D%2D%5B ...%5D%22%7D)%3B%0ACPR%3A%3A%20R%20R%20%20%20%20CPR%3A%3A%3AGET(CPR%3A%3A%3AAIRL%7b%7B%22Https %3A // www.httpbin.org/get%22%7D%2C%20SSlopts)%3B 在这种情况下,“ Cabuffer”
都会
对此表示赞赏
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,就像一个版本的问题。
authmode
存在于“ nofollow noreferrer”>最新的header文件,但不存在于版本1.8标头文件,大概是您拥有的。因此,要么降级代码,要么升级安装。
版本1.8的示例代码为在这里
Looks to me like a versioning issue.
AuthMode
exists in the latest header file, but does not exist in the version 1.8 header file, which is presumably what you have.So, either downgrade your code, or upgrade your installation.
Sample code from version 1.8 is here