about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/client.cpp34
-rw-r--r--src/client.h4
2 files changed, 36 insertions, 2 deletions
diff --git a/src/client.cpp b/src/client.cpp index ccfd9a3..c2ef06f 100644 --- a/src/client.cpp +++ b/src/client.cpp
@@ -591,7 +591,39 @@ namespace twitter {
591 { 591 {
592 return getFollowers(getUser().getID()); 592 return getFollowers(getUser().getID());
593 } 593 }
594 594
595 std::set<user_id> client::getBlocks() const
596 {
597 long long cursor = -1;
598 std::set<user_id> result;
599
600 while (cursor != 0)
601 {
602 std::stringstream urlstream;
603 urlstream << "https://api.twitter.com/1.1/blocks/ids.json?cursor=";
604 urlstream << cursor;
605
606 std::string url = urlstream.str();
607 std::string response_data = get(*_oauth_client, url).perform();
608
609 try
610 {
611 nlohmann::json rjs = nlohmann::json::parse(response_data);
612
613 cursor = rjs["next_cursor"].get<long long>();
614 result.insert(std::begin(rjs["ids"]), std::end(rjs["ids"]));
615 } catch (const std::invalid_argument& error)
616 {
617 std::throw_with_nested(invalid_response(response_data));
618 } catch (const std::domain_error& error)
619 {
620 std::throw_with_nested(invalid_response(response_data));
621 }
622 }
623
624 return result;
625 }
626
595 void client::follow(user_id toFollow) const 627 void client::follow(user_id toFollow) const
596 { 628 {
597 std::stringstream datastrstream; 629 std::stringstream datastrstream;
diff --git a/src/client.h b/src/client.h index c920f82..9282321 100644 --- a/src/client.h +++ b/src/client.h
@@ -38,7 +38,9 @@ namespace twitter {
38 std::set<user_id> getFollowers(user_id id) const; 38 std::set<user_id> getFollowers(user_id id) const;
39 std::set<user_id> getFollowers(const user& u) const; 39 std::set<user_id> getFollowers(const user& u) const;
40 std::set<user_id> getFollowers() const; 40 std::set<user_id> getFollowers() const;
41 41
42 std::set<user_id> getBlocks() const;
43
42 void follow(user_id toFollow) const; 44 void follow(user_id toFollow) const;
43 void follow(const user& toFollow) const; 45 void follow(const user& toFollow) const;
44 46