diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-05-20 15:34:44 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-05-20 15:34:44 -0400 |
commit | 0ccac89815ee92c69fefc148cfb272faf7309136 (patch) | |
tree | 228775a433018c8a5fd20f0ebb0f8446057b2112 /src/tweet.cpp | |
parent | f465dce27cf0f07039e29d8975ad98939f0df3a9 (diff) | |
download | libtwittercpp-0ccac89815ee92c69fefc148cfb272faf7309136.tar.gz libtwittercpp-0ccac89815ee92c69fefc148cfb272faf7309136.tar.bz2 libtwittercpp-0ccac89815ee92c69fefc148cfb272faf7309136.zip |
Started implementing user streams
You can now start a user stream and end it yourself. If it disconnects abnormally, it will reconnect with a backoff as described by Twitter. Some data structures have some fields parsed now; tweets have IDs, text, and authors. Users have IDs, screen names, and names. Notifications from the stream are parsed completely. The ability to follow and unfollow users has also been added, as well as the ability to get a list of friends and followers, and to reply to a tweet.
Diffstat (limited to 'src/tweet.cpp')
-rw-r--r-- | src/tweet.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/tweet.cpp b/src/tweet.cpp index 3ba3aa3..e515595 100644 --- a/src/tweet.cpp +++ b/src/tweet.cpp | |||
@@ -1,15 +1,41 @@ | |||
1 | #include "tweet.h" | 1 | #include "tweet.h" |
2 | #include <json.hpp> | ||
3 | |||
4 | using nlohmann::json; | ||
2 | 5 | ||
3 | namespace twitter { | 6 | namespace twitter { |
4 | 7 | ||
5 | tweet::tweet() | 8 | tweet::tweet() : _valid(false) |
9 | { | ||
10 | |||
11 | } | ||
12 | |||
13 | tweet::tweet(std::string data) : _valid(true) | ||
14 | { | ||
15 | auto _data = json::parse(data); | ||
16 | _id = _data.at("id"); | ||
17 | _text = _data.at("text"); | ||
18 | _author = user(_data.at("user").dump()); | ||
19 | } | ||
20 | |||
21 | tweet_id tweet::getID() const | ||
22 | { | ||
23 | return _id; | ||
24 | } | ||
25 | |||
26 | std::string tweet::getText() const | ||
27 | { | ||
28 | return _text; | ||
29 | } | ||
30 | |||
31 | const user& tweet::getAuthor() const | ||
6 | { | 32 | { |
7 | _valid = false; | 33 | return _author; |
8 | } | 34 | } |
9 | 35 | ||
10 | tweet::tweet(const json& data) | 36 | tweet::operator bool() const |
11 | { | 37 | { |
12 | _valid = true; | 38 | return _valid; |
13 | } | 39 | } |
14 | 40 | ||
15 | }; | 41 | }; |