about summary refs log tree commit diff stats
path: root/src/client.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-08-05 11:14:39 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-08-05 11:14:39 -0400
commit38203b745ae1903ba0804ed5532b78d255bea635 (patch)
tree52f57ce85e65361c534c461abc82fb1ed9768d49 /src/client.h
parent7c44fd17bb6be54a2ea4b60761e91053ca988977 (diff)
downloadlibtwittercpp-38203b745ae1903ba0804ed5532b78d255bea635.tar.gz
libtwittercpp-38203b745ae1903ba0804ed5532b78d255bea635.tar.bz2
libtwittercpp-38203b745ae1903ba0804ed5532b78d255bea635.zip
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.
Diffstat (limited to 'src/client.h')
-rw-r--r--src/client.h66
1 files changed, 37 insertions, 29 deletions
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 @@
10#include "auth.h" 10#include "auth.h"
11#include "configuration.h" 11#include "configuration.h"
12#include "util.h" 12#include "util.h"
13 13#include "timeline.h"
14namespace OAuth {
15 class Consumer;
16 class Token;
17 class Client;
18};
19 14
20namespace twitter { 15namespace twitter {
21 16
22 class client { 17 class client {
23 public: 18 public:
24 19
25 client(const auth& _auth); 20 client(const auth& arg);
26 ~client(); 21
27
28 tweet updateStatus(std::string msg, std::list<long> media_ids = {}) const; 22 tweet updateStatus(std::string msg, std::list<long> media_ids = {}) const;
29 long uploadMedia(std::string media_type, const char* data, long data_length) const; 23 long uploadMedia(std::string media_type, const char* data, long data_length) const;
30 24
31 tweet replyToTweet(std::string msg, tweet_id in_response_to, std::list<long> media_ids = {}) const; 25 tweet replyToTweet(std::string msg, tweet_id in_response_to, std::list<long> media_ids = {}) const;
32 26
33 std::set<user_id> getFriends(user_id id) const; 27 std::set<user_id> getFriends(user_id id) const;
34 std::set<user_id> getFriends(const user& u) const; 28 std::set<user_id> getFriends(const user& u) const;
35 std::set<user_id> getFriends() const; 29 std::set<user_id> getFriends() const;
36 30
37 std::set<user_id> getFollowers(user_id id) const; 31 std::set<user_id> getFollowers(user_id id) const;
38 std::set<user_id> getFollowers(const user& u) const; 32 std::set<user_id> getFollowers(const user& u) const;
39 std::set<user_id> getFollowers() const; 33 std::set<user_id> getFollowers() const;
40 34
41 void follow(user_id toFollow) const; 35 void follow(user_id toFollow) const;
42 void follow(const user& toFollow) const; 36 void follow(const user& toFollow) const;
43 37
44 void unfollow(user_id toUnfollow) const; 38 void unfollow(user_id toUnfollow) const;
45 void unfollow(const user& toUnfollow) const; 39 void unfollow(const user& toUnfollow) const;
46 40
47 const user& getUser() const; 41 const user& getUser() const;
48 42
49 const configuration& getConfiguration() const; 43 const configuration& getConfiguration() const;
50 44
45 timeline& getHomeTimeline()
46 {
47 return homeTimeline_;
48 }
49
50 timeline& getMentionsTimeline()
51 {
52 return mentionsTimeline_;
53 }
54
51 private: 55 private:
52 56
53 friend class stream; 57 const auth& auth_;
54 58
55 std::unique_ptr<OAuth::Consumer> _oauth_consumer; 59 user currentUser_;
56 std::unique_ptr<OAuth::Token> _oauth_token; 60
57 std::unique_ptr<OAuth::Client> _oauth_client;
58
59 std::unique_ptr<user> _current_user;
60
61 mutable std::unique_ptr<configuration> _configuration; 61 mutable std::unique_ptr<configuration> _configuration;
62 mutable time_t _last_configuration_update; 62 mutable time_t _last_configuration_update;
63
64 timeline homeTimeline_ {
65 auth_,
66 "https://api.twitter.com/1.1/statuses/home_timeline.json"};
67
68 timeline mentionsTimeline_ {
69 auth_,
70 "https://api.twitter.com/1.1/statuses/mentions_timeline.json"};
63 }; 71 };
64 72
65}; 73};
66 74
67#endif /* end of include guard: TWITTER_H_ABFF6A12 */ 75#endif /* end of include guard: TWITTER_H_ABFF6A12 */