From 204181c5654cee745b6b1ba98675609e784f0ee1 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 5 Aug 2018 13:21:23 -0400 Subject: Added ability to hydrate tweets --- src/client.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index b7eb9d1..0a4cf2a 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -351,4 +351,37 @@ namespace twitter { return *_configuration; } + std::list client::hydrateTweets(std::set ids) const + { + std::list result; + + while (!ids.empty()) + { + std::set cur; + + for (int i = 0; i < 100 && !ids.empty(); i++) + { + cur.insert(*std::begin(ids)); + ids.erase(std::begin(ids)); + } + + std::string datastr = "id=" + + OAuth::PercentEncode(implode(std::begin(cur), std::end(cur), ",")); + + std::string response = + post(auth_, + "https://api.twitter.com/1.1/statuses/lookup.json", + datastr).perform(); + + nlohmann::json rjs = nlohmann::json::parse(response); + + for (auto& single : rjs) + { + result.emplace_back(single.dump()); + } + } + + return result; + } + }; -- cgit 1.4.1