about summary refs log tree commit diff stats
path: root/src/client.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-08-05 13:21:23 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-08-05 13:21:23 -0400
commit204181c5654cee745b6b1ba98675609e784f0ee1 (patch)
tree6a09a6e0956fa91bfec0ac5f1ef1918773d1cf05 /src/client.cpp
parent826961600aa23645ff9200e2c1802779eb68d835 (diff)
downloadlibtwittercpp-204181c5654cee745b6b1ba98675609e784f0ee1.tar.gz
libtwittercpp-204181c5654cee745b6b1ba98675609e784f0ee1.tar.bz2
libtwittercpp-204181c5654cee745b6b1ba98675609e784f0ee1.zip
Added ability to hydrate tweets
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp33
1 files changed, 33 insertions, 0 deletions
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 {
351 return *_configuration; 351 return *_configuration;
352 } 352 }
353 353
354 std::list<tweet> client::hydrateTweets(std::set<tweet_id> ids) const
355 {
356 std::list<tweet> result;
357
358 while (!ids.empty())
359 {
360 std::set<tweet_id> cur;
361
362 for (int i = 0; i < 100 && !ids.empty(); i++)
363 {
364 cur.insert(*std::begin(ids));
365 ids.erase(std::begin(ids));
366 }
367
368 std::string datastr = "id=" +
369 OAuth::PercentEncode(implode(std::begin(cur), std::end(cur), ","));
370
371 std::string response =
372 post(auth_,
373 "https://api.twitter.com/1.1/statuses/lookup.json",
374 datastr).perform();
375
376 nlohmann::json rjs = nlohmann::json::parse(response);
377
378 for (auto& single : rjs)
379 {
380 result.emplace_back(single.dump());
381 }
382 }
383
384 return result;
385 }
386
354}; 387};