diff options
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 34 |
1 files changed, 33 insertions, 1 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; |