diff options
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 37 |
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; |