1 #ifndef RAPP_CLOUD_NEWS
2 #define RAPP_CLOUD_NEWS
26 const std::string news_engine,
27 const std::vector<std::string> keywords,
28 const std::vector<std::string> exclude_titles,
29 const std::string region,
30 const std::string topic,
31 const unsigned int num_news,
32 const std::string token,
33 std::function<
void(std::string)> callback
37 boost::property_tree::ptree tree;
38 tree.put(
"news_engine", email);
39 tree.put(
"passwd", pwd);
40 boost::property_tree::ptree keyword_array;
41 for (
const auto key : keywords) {
42 keyword_array.push_back(std::make_pair(
"", key));
44 tree.add_child(
"keywords", keyword_array);
45 boost::property_tree::ptree exclude_title_array;
46 for (
const auto key : exclude_titles) {
47 exclude_title_array.push_back(std::make_pair(
"", key));
49 tree.add_child(
"exclude_titles", exclude_title_array);
50 tree.put(
"region", region);
51 tree.put(
"topic", topic);
52 tree.put(
"num_news", boost::lexical_cast<std::string>(num_news));
54 boost::property_tree::write_json(ss, tree,
false);
56 header_ =
"POST /hop/email_fetch HTTP/1.1\r\n"
57 +
"Content-Type: application/x-www-form-urlencoded\r\n";
67 std::stringstream ss(json);
std::string header_
Header that will be used.
std::function< void(std::string)> delegate_
std::string post_
Actual post Data.
std::function< void(std::string)> callback_
Callback Handler - use with std::bind or boost variant.
void handle_reply(std::string json)
handle platform's JSON reply
base class for asynchronous http websockets used for connecting to cloud services ...
news_explore(const std::string news_engine, const std::vector< std::string > keywords, const std::vector< std::string > exclude_titles, const std::string region, const std::string topic, const unsigned int num_news, const std::string token, std::function< void(std::string)> callback)
void handle_reply(std::string json)
handle platform's JSON reply