From e506eb6214ac1799ce7d7e333cfab965a11d5917 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 2 Jun 2016 20:10:08 -0400 Subject: Fixed user stream unable-to-reconnect issue --- src/client.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index b7d1624..51c288d 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -661,7 +661,6 @@ namespace twitter { void client::stream::run() { - curl::curl_easy conn; std::ostringstream urlstr; urlstr << "https://userstream.twitter.com/1.1/user.json"; @@ -671,29 +670,31 @@ namespace twitter { } std::string url = urlstr.str(); - curl::curl_header headers; - std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, ""); - if (!oauth_header.empty()) - { - headers.add(oauth_header); - } - - conn.add(client_stream_write_callback_wrapper); - conn.add(this); - conn.add(nullptr); - conn.add(nullptr); - conn.add(client_stream_progress_callback_wrapper); - conn.add(this); - conn.add(0); - //conn.add(1); - //conn.add(my_trace); - conn.add(url.c_str()); - conn.add(headers.get()); _backoff_type = backoff::none; _backoff_amount = std::chrono::milliseconds(0); for (;;) { + curl::curl_easy conn; + curl::curl_header headers; + std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, ""); + if (!oauth_header.empty()) + { + headers.add(oauth_header); + } + + conn.add(client_stream_write_callback_wrapper); + conn.add(this); + conn.add(nullptr); + conn.add(nullptr); + conn.add(client_stream_progress_callback_wrapper); + conn.add(this); + conn.add(0); + //conn.add(1); + //conn.add(my_trace); + conn.add(url.c_str()); + conn.add(headers.get()); + bool failure = false; try { conn.perform(); -- cgit 1.4.1 From c3cc76301d64320791f7097709ffcd36d7206266 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 12 Jun 2016 10:26:36 -0400 Subject: Added method to Tweet to get URL --- src/tweet.cpp | 5 +++++ src/tweet.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/tweet.cpp b/src/tweet.cpp index 2927018..193df6e 100644 --- a/src/tweet.cpp +++ b/src/tweet.cpp @@ -126,6 +126,11 @@ namespace twitter { return _mentions; } + std::string tweet::getURL() const + { + return "https://twitter.com/" + _author.getScreenName() + "/statuses/" + std::to_string(_id); + } + tweet::operator bool() const { return _valid; diff --git a/src/tweet.h b/src/tweet.h index 387f73a..74d73d2 100644 --- a/src/tweet.h +++ b/src/tweet.h @@ -27,6 +27,7 @@ namespace twitter { bool isRetweet() const; tweet getRetweet() const; std::vector> getMentions() const; + std::string getURL() const; operator bool() const; -- cgit 1.4.1