Documentation update, saving access_token
This commit is contained in:
parent
d11273ddc0
commit
8222ff6da1
|
@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.7)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
project (mastodon-cpp
|
project (mastodon-cpp
|
||||||
VERSION 0.2.13
|
VERSION 0.2.14
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||||
|
|
|
@ -98,8 +98,7 @@ const std::uint16_t API::http::request_sync(const method &meth,
|
||||||
answer = oss.str();
|
answer = oss.str();
|
||||||
}
|
}
|
||||||
else if (ret == 301 || ret == 308)
|
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
|
// FIXME: The new URL should be passed back somehow
|
||||||
answer = oss.str();
|
answer = oss.str();
|
||||||
}
|
}
|
||||||
|
@ -111,6 +110,7 @@ const std::uint16_t API::http::request_sync(const method &meth,
|
||||||
catch (curlpp::RuntimeError &e)
|
catch (curlpp::RuntimeError &e)
|
||||||
{
|
{
|
||||||
cerr << "RUNTIME ERROR: " << e.what() << std::endl;
|
cerr << "RUNTIME ERROR: " << e.what() << std::endl;
|
||||||
|
|
||||||
return 0xffff;
|
return 0xffff;
|
||||||
}
|
}
|
||||||
catch (curlpp::LogicError &e)
|
catch (curlpp::LogicError &e)
|
||||||
|
|
|
@ -225,6 +225,7 @@ const std::uint16_t API::register_app2(const string &instance,
|
||||||
|
|
||||||
std::regex_search(answer, match, retoken);
|
std::regex_search(answer, match, retoken);
|
||||||
access_token = match[1].str();
|
access_token = match[1].str();
|
||||||
|
_access_token = access_token;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
* @example example3_mastocron.cpp
|
* @example example3_mastocron.cpp
|
||||||
* @example example4_update_credentials.cpp
|
* @example example4_update_credentials.cpp
|
||||||
* @example example5_follow_unfollow.cpp
|
* @example example5_follow_unfollow.cpp
|
||||||
|
* @example example6_toot_delete-toot.cpp
|
||||||
|
* @example example7_register_app.cpp
|
||||||
*/
|
*/
|
||||||
namespace Mastodon
|
namespace Mastodon
|
||||||
{
|
{
|
||||||
|
@ -133,9 +135,11 @@ public:
|
||||||
/*!
|
/*!
|
||||||
* @brief Constructs a new API object.
|
* @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 instance The hostname of your instance
|
||||||
* @param access_token Your access token. You have to generate it
|
* @param access_token Your access token.
|
||||||
* manually for now.
|
|
||||||
*/
|
*/
|
||||||
explicit API(const std::string &instance,
|
explicit API(const std::string &instance,
|
||||||
const std::string &access_token);
|
const std::string &access_token);
|
||||||
|
@ -194,6 +198,8 @@ public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Register application, step 2/2
|
* @brief Register application, step 2/2
|
||||||
|
*
|
||||||
|
* The access token will be used in all subsequent calls.
|
||||||
*
|
*
|
||||||
* @param instance
|
* @param instance
|
||||||
* @param client_id
|
* @param client_id
|
||||||
|
@ -457,7 +463,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string _instance;
|
const std::string _instance;
|
||||||
const std::string _access_token;
|
std::string _access_token;
|
||||||
std::string _useragent;
|
std::string _useragent;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
Reference in New Issue