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 +++++++++++++++++++++++++++++++++ src/client.h | 2 ++ 2 files changed, 35 insertions(+) (limited to 'src') 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; + } + }; diff --git a/src/client.h b/src/client.h index 5e2ab1c..6eb8181 100644 --- a/src/client.h +++ b/src/client.h @@ -55,6 +55,8 @@ namespace twitter { return mentionsTimeline_; } + std::list hydrateTweets(std::set ids) const; + private: const auth& auth_; -- cgit 1.4.1