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/user.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/user.cpp (limited to 'src/user.cpp') diff --git a/src/user.cpp b/src/user.cpp new file mode 100644 index 0000000..9352938 --- /dev/null +++ b/src/user.cpp @@ -0,0 +1,46 @@ +#include "user.h" +#include + +using nlohmann::json; + +namespace twitter { + + user::user() : _valid(false) + { + + } + + user::user(std::string data) : _valid(true) + { + auto _data = json::parse(data); + _id = _data.at("id"); + _screen_name = _data.at("screen_name"); + _name = _data.at("name"); + } + + user_id user::getID() const + { + return _id; + } + + std::string user::getScreenName() const + { + return _screen_name; + } + + std::string user::getName() const + { + return _name; + } + + user::operator bool() const + { + return _valid; + } + + bool user::operator==(const user& other) const + { + return _id == other._id; + } + +}; -- cgit 1.4.1