From 8222ff6da1968046091c1665e1671379e229ec8b Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 11 Feb 2018 12:26:42 +0100 Subject: [PATCH] Documentation update, saving access_token --- CMakeLists.txt | 2 +- src/http_sync.cpp | 4 ++-- src/mastodon-cpp.cpp | 1 + src/mastodon-cpp.hpp | 12 +++++++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8665766..976f898 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.7) include(GNUInstallDirs) project (mastodon-cpp - VERSION 0.2.13 + VERSION 0.2.14 LANGUAGES CXX ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") diff --git a/src/http_sync.cpp b/src/http_sync.cpp index 4bbdde9..e51151e 100644 --- a/src/http_sync.cpp +++ b/src/http_sync.cpp @@ -98,8 +98,7 @@ const std::uint16_t API::http::request_sync(const method &meth, answer = oss.str(); } else if (ret == 301 || ret == 308) - { - // Moved Permanently or Permanent Redirect + { // Moved Permanently or Permanent Redirect // FIXME: The new URL should be passed back somehow answer = oss.str(); } @@ -111,6 +110,7 @@ const std::uint16_t API::http::request_sync(const method &meth, catch (curlpp::RuntimeError &e) { cerr << "RUNTIME ERROR: " << e.what() << std::endl; + return 0xffff; } catch (curlpp::LogicError &e) diff --git a/src/mastodon-cpp.cpp b/src/mastodon-cpp.cpp index 0115f8b..8cdd662 100644 --- a/src/mastodon-cpp.cpp +++ b/src/mastodon-cpp.cpp @@ -225,6 +225,7 @@ const std::uint16_t API::register_app2(const string &instance, std::regex_search(answer, match, retoken); access_token = match[1].str(); + _access_token = access_token; return 0; } diff --git a/src/mastodon-cpp.hpp b/src/mastodon-cpp.hpp index 5e70916..cb4f2b6 100644 --- a/src/mastodon-cpp.hpp +++ b/src/mastodon-cpp.hpp @@ -30,6 +30,8 @@ * @example example3_mastocron.cpp * @example example4_update_credentials.cpp * @example example5_follow_unfollow.cpp + * @example example6_toot_delete-toot.cpp + * @example example7_register_app.cpp */ namespace Mastodon { @@ -133,9 +135,11 @@ public: /*! * @brief Constructs a new API object. * + * To register your application, leave access_token blank and call + * register_app1() and register_app2(). + * * @param instance The hostname of your instance - * @param access_token Your access token. You have to generate it - * manually for now. + * @param access_token Your access token. */ explicit API(const std::string &instance, const std::string &access_token); @@ -194,6 +198,8 @@ public: /*! * @brief Register application, step 2/2 + * + * The access token will be used in all subsequent calls. * * @param instance * @param client_id @@ -457,7 +463,7 @@ public: private: const std::string _instance; - const std::string _access_token; + std::string _access_token; std::string _useragent; /*!