about summary refs log tree commit diff stats
path: root/src/client.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-02-23 11:20:55 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-02-23 11:20:55 -0500
commit5014ad408ace1dda89e0e9852db4a001b605c0a2 (patch)
tree5831cc9546038cc3dc9a11fba05692346f06d6dc /src/client.cpp
parentd1d20515281e32b23657762e72bf37dcff14f0ab (diff)
downloadlibtwittercpp-5014ad408ace1dda89e0e9852db4a001b605c0a2.tar.gz
libtwittercpp-5014ad408ace1dda89e0e9852db4a001b605c0a2.tar.bz2
libtwittercpp-5014ad408ace1dda89e0e9852db4a001b605c0a2.zip
Added ability to get blocklist
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp34
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;