From 38203b745ae1903ba0804ed5532b78d255bea635 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 5 Aug 2018 11:14:39 -0400 Subject: Added timeline polling Because the streaming API will sunset on August 16th, it is essential to implement timeline polling so that the library can still be used to access tweets. This commit breaks the current API even for clients still using the streaming API because the OAuth connection data was pulled from twitter::client into twitter::auth. Other than that, almost everything works the same, and if a client wants to update their libtwitter++ within the next week and a half, they are free to. --- src/client.h | 66 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 29 deletions(-) (limited to 'src/client.h') diff --git a/src/client.h b/src/client.h index 2230dbb..c0a63eb 100644 --- a/src/client.h +++ b/src/client.h @@ -10,58 +10,66 @@ #include "auth.h" #include "configuration.h" #include "util.h" - -namespace OAuth { - class Consumer; - class Token; - class Client; -}; +#include "timeline.h" namespace twitter { - + class client { public: - - client(const auth& _auth); - ~client(); - + + client(const auth& arg); + tweet updateStatus(std::string msg, std::list media_ids = {}) const; long uploadMedia(std::string media_type, const char* data, long data_length) const; - + tweet replyToTweet(std::string msg, tweet_id in_response_to, std::list media_ids = {}) const; - + std::set getFriends(user_id id) const; std::set getFriends(const user& u) const; std::set getFriends() const; - + std::set getFollowers(user_id id) const; std::set getFollowers(const user& u) const; std::set getFollowers() const; - + void follow(user_id toFollow) const; void follow(const user& toFollow) const; - + void unfollow(user_id toUnfollow) const; void unfollow(const user& toUnfollow) const; - + const user& getUser() const; - + const configuration& getConfiguration() const; - + + timeline& getHomeTimeline() + { + return homeTimeline_; + } + + timeline& getMentionsTimeline() + { + return mentionsTimeline_; + } + private: - - friend class stream; - - std::unique_ptr _oauth_consumer; - std::unique_ptr _oauth_token; - std::unique_ptr _oauth_client; - - std::unique_ptr _current_user; - + + const auth& auth_; + + user currentUser_; + mutable std::unique_ptr _configuration; mutable time_t _last_configuration_update; + + timeline homeTimeline_ { + auth_, + "https://api.twitter.com/1.1/statuses/home_timeline.json"}; + + timeline mentionsTimeline_ { + auth_, + "https://api.twitter.com/1.1/statuses/mentions_timeline.json"}; }; - + }; #endif /* end of include guard: TWITTER_H_ABFF6A12 */ -- cgit 1.4.1