17 #ifndef MASTODON_CPP_HPP 18 #define MASTODON_CPP_HPP 27 #include <curlpp/cURLpp.hpp> 28 #include <curlpp/Easy.hpp> 30 using std::uint_fast16_t;
101 explicit http(
const API &api,
const string &instance,
102 const string &access_token);
104 uint_fast16_t request(
const method &meth,
121 uint_fast16_t request(
const method &meth,
123 const curlpp::Forms &formdata,
143 [[deprecated(
"Will vanish in 1.0.0. Use cancel_stream() instead.")]]
160 const string _instance;
161 const string _access_token;
166 size_t callback_write(
char* data,
size_t size,
size_t nmemb,
168 [[deprecated(
"Will vanish in 1.0.0. Use callback_write() instead.")]]
169 size_t callback(
char* data,
size_t size,
size_t nmemb,
171 double callback_progress(
double ,
double ,
201 accounts_verify_credentials,
202 accounts_id_followers,
203 accounts_id_following,
204 accounts_id_statuses,
205 accounts_relationships,
226 statuses_id_reblogged_by,
227 statuses_id_favourited_by,
230 timelines_tag_hashtag,
231 timelines_list_list_id,
233 accounts_update_credentials,
236 accounts_id_unfollow,
244 follow_requests_id_authorize,
245 follow_requests_id_reject,
249 notifications_dismiss,
252 statuses_id_unreblog,
253 statuses_id_favourite,
254 statuses_id_unfavourite,
264 streaming_public_local,
271 statuses_id_bookmark,
272 statuses_id_unbookmark
298 explicit API(
const string &instance,
const string &access_token);
344 static const string urlencode(
const string &str);
359 static const string urldecode(
const string &str);
379 const string &redirect_uri,
380 const string &scopes,
381 const string &website,
383 string &client_secret,
386 [[deprecated(
"Will vanish in 1.0.0")]]
388 const string &client_name,
389 const string &redirect_uri,
390 const string &scopes,
391 const string &website,
393 string &client_secret,
412 const string &client_secret,
413 const string &redirect_uri,
415 string &access_token);
417 [[deprecated(
"Will vanish in 1.0.0")]]
419 const string &client_id,
420 const string &client_secret,
421 const string &redirect_uri,
423 string &access_token);
434 const string get_header(
const string &header)
const;
475 void set_proxy(
const string &proxy,
const string &userpw =
"");
485 void get_proxy(
string &proxy,
string &userpw)
const;
536 uint_fast16_t
get(
const string &call,
string &answer);
538 [[deprecated(
"Will vanish in 1.0.0, use get() without string argument " 541 const string &argument,
544 [[deprecated(
"Will vanish in 1.0.0, use get() without string argument " 547 const string &argument,
568 std::unique_ptr<Mastodon::API::http> &ptr);
585 std::unique_ptr<Mastodon::API::http> &ptr);
603 std::unique_ptr<Mastodon::API::http> &ptr);
605 [[deprecated(
"Will vanish in 1.0.0, use get_stream() without string " 606 "argument instead.")]]
608 const string &argument,
610 std::unique_ptr<Mastodon::API::http> &ptr);
679 uint_fast16_t
post(
const string &call,
683 [[deprecated(
"Will vanish in 1.0.0, use post() without string argument " 686 const string &argument,
689 [[deprecated(
"Will vanish in 1.0.0, use post() without string argument " 692 const string &argument,
728 uint_fast16_t
put(
const string &call,
732 [[deprecated(
"Will vanish in 1.0.0, use put() without string argument " 735 const string &argument,
765 uint_fast16_t
del(
const string &call,
769 [[deprecated(
"Will vanish in 1.0.0, use del() without string argument " 772 const string &argument);
774 [[deprecated(
"Will vanish in 1.0.0, use del() without string argument " 777 const string &argument,
781 const string _instance;
782 string _access_token;
787 string _proxy_userpw;
798 const bool &firstparam =
true);
807 const curlpp::Forms maptoformdata(
const parametermap &map);
void set_proxy(const string &proxy, const string &userpw="")
Sets the proxy.
Definition: mastodon-cpp.cpp:589
void get_proxy(string &proxy, string &userpw) const
For internal use.
Definition: mastodon-cpp.cpp:595
Class for the Mastodon API.
Definition: mastodon-cpp.hpp:77
uint_fast16_t register_app1(const string &client_name, const string &redirect_uri, const string &scopes, const string &website, string &client_id, string &client_secret, string &url)
Register application, step 1/2.
Definition: mastodon-cpp.cpp:163
static const string urlencode(const string &str)
Percent-encodes a string. This is done automatically, unless you make a custom request.
Definition: mastodon-cpp.cpp:141
void get_headers(string &headers) const
Get all headers in a string.
Definition: http.cpp:199
static const string urldecode(const string &str)
Decodes a percent-encoded string.
Definition: mastodon-cpp.cpp:146
v1
A list of all v1 API calls.
Definition: mastodon-cpp.hpp:198
uint_fast16_t del(const Mastodon::API::v1 &call, const parametermap ¶meters)
Make a DELETE request which requires parameters.
Definition: delete.cpp:23
v2
A list of all v2 API calls.
Definition: mastodon-cpp.hpp:282
const string get_header(const string &header) const
Gets the header from the last answer.
Definition: mastodon-cpp.cpp:262
uint_fast16_t patch(const Mastodon::API::v1 &call, const parametermap ¶meters, string &answer)
Make a PATCH request.
Definition: patch.cpp:24
API(const string &instance, const string &access_token)
Constructs a new API object.
Definition: mastodon-cpp.cpp:30
uint_fast16_t post(const Mastodon::API::v1 &call, string &answer)
Make a POST request which doesn't require parameters.
Definition: post.cpp:140
method
HTTP methods.
Definition: mastodon-cpp.hpp:91
void cancel_stream()
Cancels the stream. Use only with streams.
Definition: http.cpp:230
uint_fast16_t put(const Mastodon::API::v1 &call, const parametermap ¶meters, string &answer)
Make a PUT request which requires a parameters.
Definition: put.cpp:23
bool exceptions() const
Returns true if exceptions are turned on, false otherwise.
Definition: mastodon-cpp.cpp:283
uint_fast16_t register_app2(const string &client_id, const string &client_secret, const string &redirect_uri, const string &code, string &access_token)
Register application, step 2/2.
Definition: mastodon-cpp.cpp:227
uint_fast16_t get_stream(const Mastodon::API::v1 &call, const parametermap ¶meters, string &answer, std::unique_ptr< Mastodon::API::http > &ptr)
Make a streaming GET request.
Definition: get_stream.cpp:24
void set_useragent(const string &useragent)
Sets the useragent. Default is mastodon-cpp/version.
Definition: mastodon-cpp.cpp:42
Definition: mastodon-cpp.hpp:52
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:189
static const string unescape_html(const string &html)
Replaces HTML entities with UTF-8 characters.
Definition: mastodon-cpp.cpp:288
const string get_instance() const
Returns the instance.
Definition: mastodon-cpp.cpp:52
http class. Do not use this directly.
Definition: mastodon-cpp.hpp:85
const string get_useragent() const
Gets the useragent.
Definition: mastodon-cpp.cpp:47
std::mutex & get_mutex()
Gets the mutex guarding the string that is written to.
Definition: http.cpp:240