From 4963c3dd55b765a33a16a77af432f2bfa12b8359 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 6 Aug 2018 16:15:35 -0400 Subject: Added ability to hydrate user objects --- 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 0a4cf2a..3a01c90 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -384,4 +384,37 @@ namespace twitter { return result; } + std::list client::hydrateUsers(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 = "user_id=" + + OAuth::PercentEncode(implode(std::begin(cur), std::end(cur), ",")); + + std::string response = + post(auth_, + "https://api.twitter.com/1.1/users/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