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 11:21:11 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-08-05 11:21:11 -0400
commit826961600aa23645ff9200e2c1802779eb68d835 (patch)
tree5392c90628cd559b00f4908028bd987f2a045b3a /src/client.cpp
parent38203b745ae1903ba0804ed5532b78d255bea635 (diff)
parent3e292e37a1313e22f13ef4b7f342c6002ea6a947 (diff)
downloadlibtwittercpp-826961600aa23645ff9200e2c1802779eb68d835.tar.gz
libtwittercpp-826961600aa23645ff9200e2c1802779eb68d835.tar.bz2
libtwittercpp-826961600aa23645ff9200e2c1802779eb68d835.zip
Merge branch 'master' of https://github.com/hatkirby/libtwittercpp
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/client.cpp b/src/client.cpp index 820db80..b7eb9d1 100644 --- a/src/client.cpp +++ b/src/client.cpp
@@ -56,6 +56,11 @@ namespace twitter {
56 .perform()); 56 .perform());
57 } 57 }
58 58
59 tweet client::replyToTweet(std::string msg, const tweet& in_response_to, std::list<long> media_ids) const
60 {
61 return replyToTweet(msg, in_response_to.getID(), media_ids);
62 }
63
59 long client::uploadMedia(std::string media_type, const char* data, long data_length) const try 64 long client::uploadMedia(std::string media_type, const char* data, long data_length) const try
60 { 65 {
61 curl::curl_form form; 66 curl::curl_form form;
@@ -265,6 +270,38 @@ namespace twitter {
265 return getFollowers(getUser().getID()); 270 return getFollowers(getUser().getID());
266 } 271 }
267 272
273 std::set<user_id> client::getBlocks() const
274 {
275 long long cursor = -1;
276 std::set<user_id> result;
277
278 while (cursor != 0)
279 {
280 std::stringstream urlstream;
281 urlstream << "https://api.twitter.com/1.1/blocks/ids.json?cursor=";
282 urlstream << cursor;
283
284 std::string url = urlstream.str();
285 std::string response_data = get(auth_, url).perform();
286
287 try
288 {
289 nlohmann::json rjs = nlohmann::json::parse(response_data);
290
291 cursor = rjs["next_cursor"].get<long long>();
292 result.insert(std::begin(rjs["ids"]), std::end(rjs["ids"]));
293 } catch (const std::invalid_argument& error)
294 {
295 std::throw_with_nested(invalid_response(response_data));
296 } catch (const std::domain_error& error)
297 {
298 std::throw_with_nested(invalid_response(response_data));
299 }
300 }
301
302 return result;
303 }
304
268 void client::follow(user_id toFollow) const 305 void client::follow(user_id toFollow) const
269 { 306 {
270 std::stringstream datastrstream; 307 std::stringstream datastrstream;