From 0ccac89815ee92c69fefc148cfb272faf7309136 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 20 May 2016 15:34:44 -0400 Subject: 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. --- src/tweet.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'src/tweet.cpp') 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 @@ #include "tweet.h" +#include + +using nlohmann::json; namespace twitter { - tweet::tweet() + tweet::tweet() : _valid(false) + { + + } + + tweet::tweet(std::string data) : _valid(true) + { + auto _data = json::parse(data); + _id = _data.at("id"); + _text = _data.at("text"); + _author = user(_data.at("user").dump()); + } + + tweet_id tweet::getID() const + { + return _id; + } + + std::string tweet::getText() const + { + return _text; + } + + const user& tweet::getAuthor() const { - _valid = false; + return _author; } - tweet::tweet(const json& data) + tweet::operator bool() const { - _valid = true; + return _valid; } }; -- cgit 1.4.1