c++ - 使用 C++ REST SDK 创建 HTTP 客户端
问题描述
我是 C++ 新手,最近尝试了C++ REST SDK:但我似乎无法按照此处的教程创建 http_client 对象。我现在完全被卡住了:/
我正在使用 Linux Mint 和最新版本的 Eclipse。当我将鼠标悬停在http_client client(U("http://www.bing.com/"))
它说的对象上时Invalid arguments 'Candidates are: http_client(const web::http::client::http_client &)'
。我只尝试了字符串,http_client client("http://www.bing.com/")
结果相同。我查看了文档,它只是说要提供一个字符串。我搜索了不同的教程和帖子,它要么只使用字符串“http://...”,要么使用宏 U, U("http://www.bing.com/")
。
我还查看了“什么是实用程序::string_t 和 'U' 宏?”部分。在Github上,但我不确定除了使用 U 来创建正确类型的字符串文字外,我还不确定它的用途,具体取决于您使用的操作系统。
#include <iostream>
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
using namespace utility; // Common utilities like string conversions
using namespace web; // Common features like URIs.
using namespace web::http; // Common HTTP functionality
using namespace web::http::client; // HTTP client features
using namespace concurrency::streams; // Asynchronous streams
int main()
{
auto fileStream = std::make_shared<ostream>();
// Open stream to output file.
pplx::task<void> requestTask = fstream::open_ostream(U("results.html")).then([=](ostream outFile)
{
*fileStream = outFile;
http_client client(U("http://www.bing.com/"));
});
return 0;
}
解决方案
推荐阅读
- uml - 逻辑流与控制流
- angularjs - ngRoute Params url 刷新不工作
- java - 如何遍历自定义列表?
- javascript - 使用 Facebook 登录时,我的 react native 应用程序没有更新 redux 商店
- python - 本机 python - 循环数据框并将记录插入数据库
- python - tkinter 小部件在尝试执行时不显示
- python - 来自文件夹的文件列表的 tkinter 组合框
- reactjs - 我在字段中有必需的值,需要使用 setState 在反应中将值从 value、value1、value2、value3、value4 字段复制到课程对象
- php - PHP中的标头('位置:')未重定向
- android - 错误“路径”参数必须是字符串类型。收到的型号