diff --git a/docs/account_8hpp_source.html b/docs/account_8hpp_source.html index 12b623e..48dc88d 100644 --- a/docs/account_8hpp_source.html +++ b/docs/account_8hpp_source.html @@ -19,7 +19,7 @@
mastodon-cpp -  0.18.4 +  0.18.8
@@ -47,35 +47,42 @@ $(function() {
account.hpp
-
1 /* This file is part of mastodon-cpp.
2  * Copyright © 2018 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef MASTODON_CPP_EASY_ACCOUNT_HPP
18 #define MASTODON_CPP_EASY_ACCOUNT_HPP
19 
20 #include <string>
21 #include <cstdint>
22 #include <chrono>
23 #include <vector>
24 #include <utility>
25 
26 // If we are compiling mastodon-cpp, use another include path
27 #ifdef MASTODON_CPP
28  #include "mastodon-cpp.hpp"
29  #include "easy/easy.hpp"
30 #else
31  #include <mastodon-cpp/mastodon-cpp.hpp>
32  #include <mastodon-cpp/easy/easy.hpp>
33 #endif
34 
35 using std::string;
36 using std::uint_fast64_t;
37 using std::chrono::system_clock;
38 
39 namespace Mastodon
40 {
46  class Easy::Account : public Easy::Entity
47  {
48  public:
54  using fields_pair = std::pair<const string, const string>;
55 
63  explicit Account(const string &json);
64 
70  Account();
71 
72  virtual const bool valid() const;
73 
82  const string acct() const;
83 
89  const string avatar() const;
90 
96  const string avatar_static() const;
97 
103  const bool bot() const;
104 
110  const system_clock::time_point created_at() const;
111 
117  const string display_name() const;
118 
124  const std::vector<fields_pair> fields() const;
125 
131  const uint_fast64_t followers_count() const;
132 
138  const uint_fast64_t following_count() const;
139 
145  const string header() const;
146 
152  const string header_static() const;
153 
159  const uint_fast64_t id() const;
160 
166  const bool locked() const;
167 
173  const bool has_moved() const;
174 
181  const Account moved() const;
182 
188  const string note() const;
189 
195  const string note_plain() const;
196 
202  const visibility_type privacy() const;
203 
209  const bool sensitive() const;
210 
216  const uint_fast64_t statuses_count() const;
217 
223  const string url() const;
224 
230  const string username() const;
231 };
232 }
233 
234 #endif // MASTODON_CPP_EASY_ACCOUNT_HPP
const string avatar() const
Returns URL of avatar.
Definition: account.cpp:61
-
const uint_fast64_t statuses_count() const
Returns number of statuses.
Definition: account.cpp:186
-
const std::vector< fields_pair > fields() const
Returns metadata fields.
Definition: account.cpp:86
-
const string header() const
Returns URL of header image.
Definition: account.cpp:114
-
const system_clock::time_point created_at() const
Returns time of creation.
Definition: account.cpp:76
-
const string avatar_static() const
Returns URL of static avatar.
Definition: account.cpp:66
-
const visibility_type privacy() const
Returns default privacy of new toots.
Definition: account.cpp:165
-
const string note_plain() const
Returns plaintext version of note.
Definition: account.cpp:160
+
1 /* This file is part of mastodon-cpp.
2  * Copyright © 2018 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef MASTODON_CPP_EASY_ACCOUNT_HPP
18 #define MASTODON_CPP_EASY_ACCOUNT_HPP
19 
20 #include <string>
21 #include <cstdint>
22 #include <chrono>
23 #include <vector>
24 #include <utility>
25 
26 // If we are compiling mastodon-cpp, use another include path
27 #ifdef MASTODON_CPP
28  #include "mastodon-cpp.hpp"
29  #include "easy/easy.hpp"
30 #else
31  #include <mastodon-cpp/mastodon-cpp.hpp>
32  #include <mastodon-cpp/easy/easy.hpp>
33 #endif
34 
35 using std::string;
36 using std::uint_fast64_t;
37 using std::chrono::system_clock;
38 
39 namespace Mastodon
40 {
46  class Easy::Account : public Easy::Entity
47  {
48  public:
54  using fields_pair = std::pair<const string, const string>;
55 
63  explicit Account(const string &json);
64 
70  Account();
71 
72  virtual const bool valid() const;
73 
82  const string acct() const;
83 
89  const string avatar() const;
90 
98  Account avatar(const string &avatar);
99 
105  const string avatar_static() const;
106 
112  const bool bot() const;
113 
119  const system_clock::time_point created_at() const;
120 
126  const string display_name() const;
127 
133  Account display_name(const string &display_name);
134 
140  const std::vector<fields_pair> fields() const;
141 
147  Account fields(std::vector<fields_pair> &fields);
148 
154  const uint_fast64_t followers_count() const;
155 
161  const uint_fast64_t following_count() const;
162 
168  const string header() const;
169 
177  Account header(const string &header);
178 
184  const string header_static() const;
185 
191  const uint_fast64_t id() const;
192 
198  const bool locked() const;
199 
205  Account locked(const bool &locked);
206 
212  const bool has_moved() const;
213 
220  const Account moved() const;
221 
227  const string note() const;
228 
234  Account note(const string &note);
235 
241  [[deprecated("Will vanish in 1.0.0. Use source() instead.")]]
242  const string note_plain() const;
243 
249  const visibility_type privacy() const;
250 
256  const bool sensitive() const;
257 
263  class Source : public Easy::Entity
264  {
265  public:
273  explicit Source(const string &json);
274 
280  Source();
281 
282  virtual const bool valid() const;
283 
289  const std::vector<fields_pair> fields() const;
290 
296  Source fields(std::vector<fields_pair> &fields);
297 
303  const string note() const;
304 
310  Source note(const string &note);
311 
317  const visibility_type privacy() const;
318 
325 
331  const bool sensitive() const;
332 
338  Source sensitive(const bool &sensitive);
339  };
340 
341  const Source source() const;
342  Account source(const Source &source);
343 
349  const uint_fast64_t statuses_count() const;
350 
356  const string url() const;
357 
363  const string username() const;
364 };
365 }
366 
367 #endif // MASTODON_CPP_EASY_ACCOUNT_HPP
const string avatar() const
Returns URL of avatar.
Definition: account.cpp:61
+
const uint_fast64_t statuses_count() const
Returns number of statuses.
Definition: account.cpp:362
+
const std::vector< fields_pair > fields() const
Returns metadata fields.
Definition: account.cpp:98
+
const string header() const
Returns URL of header image.
Definition: account.cpp:141
+
const system_clock::time_point created_at() const
Returns time of creation.
Definition: account.cpp:82
+
const string avatar_static() const
Returns URL of static avatar.
Definition: account.cpp:72
+
const visibility_type privacy() const
Returns default privacy of new toots.
Definition: account.cpp:210
+
const string note_plain() const
Returns plaintext version of note.
Definition: account.cpp:205
+
const std::vector< fields_pair > fields() const
Returns metadata fields.
Definition: account.cpp:244
const string acct() const
Returns username.
Definition: account.cpp:56
-
const bool has_moved() const
Returns true if the account has been moved.
Definition: account.cpp:134
+
const bool has_moved() const
Returns true if the account has been moved.
Definition: account.cpp:173
std::pair< const string, const string > fields_pair
Describes a field. Format: name, value.
Definition: account.hpp:54
-
const uint_fast64_t followers_count() const
Returns number of followers.
Definition: account.cpp:104
-
const string note() const
Returns note.
Definition: account.cpp:155
-
const string header_static() const
Returns URL of static header image.
Definition: account.cpp:119
+
const uint_fast64_t followers_count() const
Returns number of followers.
Definition: account.cpp:131
+
const string note() const
Returns note.
Definition: account.cpp:194
+
const string note() const
Returns note in plain text.
Definition: account.cpp:278
+
Source()
Constructs an empty Account::Source object.
Definition: account.cpp:235
+
const visibility_type privacy() const
Returns default privacy of new toots.
Definition: account.cpp:289
+
const string header_static() const
Returns URL of static header image.
Definition: account.cpp:152
+
virtual const bool valid() const
Returns true if the Entity holds valid data.
Definition: account.cpp:239
visibility_type
Describes visibility of toots.
Definition: easy.hpp:68
-
const uint_fast64_t id() const
Returns account-ID.
Definition: account.cpp:124
-
const string username() const
Returns username (without )
Definition: account.cpp:196
-
const bool locked() const
Returns true if the account is locked.
Definition: account.cpp:129
+
const uint_fast64_t id() const
Returns account-ID.
Definition: account.cpp:157
+
const string username() const
Returns username (without )
Definition: account.cpp:372
+
const bool locked() const
Returns true if the account is locked.
Definition: account.cpp:162
virtual const bool valid() const
Returns true if the Entity holds valid data.
Definition: account.cpp:32
-
const string display_name() const
Returns display name.
Definition: account.cpp:81
+
const string display_name() const
Returns display name.
Definition: account.cpp:87
Class to hold accounts.
Definition: account.hpp:46
-
const Account moved() const
If the owner decided to switch accounts, new account is in this attribute.
Definition: account.cpp:144
-
const bool sensitive() const
Returns if media is marked as sensitive by default.
Definition: account.cpp:181
+
const Account moved() const
If the owner decided to switch accounts, new account is in this attribute.
Definition: account.cpp:183
+
const bool sensitive() const
Returns if media is marked as sensitive by default.
Definition: account.cpp:340
+
const bool sensitive() const
Returns if media is marked as sensitive by default.
Definition: account.cpp:226
Definition: mastodon-cpp.hpp:52
Base class for all entities.
Definition: easy.hpp:304
-
const uint_fast64_t following_count() const
Returns number of people this account follows.
Definition: account.cpp:109
+
Class to hold source attribute.
Definition: account.hpp:263
+
const uint_fast64_t following_count() const
Returns number of people this account follows.
Definition: account.cpp:136
Account()
Constructs an empty Account object.
Definition: account.cpp:28
-
const bool bot() const
Returns true if the account performs automated actions.
Definition: account.cpp:71
-
const string url() const
Returns URL of the profile.
Definition: account.cpp:191
+
const bool bot() const
Returns true if the account performs automated actions.
Definition: account.cpp:77
+
const string url() const
Returns URL of the profile.
Definition: account.cpp:367
diff --git a/docs/application_8hpp_source.html b/docs/application_8hpp_source.html index 733fa34..a0c3042 100644 --- a/docs/application_8hpp_source.html +++ b/docs/application_8hpp_source.html @@ -19,7 +19,7 @@
mastodon-cpp -  0.18.4 +  0.18.8
diff --git a/docs/attachment_8hpp_source.html b/docs/attachment_8hpp_source.html index 92efc77..82200f4 100644 --- a/docs/attachment_8hpp_source.html +++ b/docs/attachment_8hpp_source.html @@ -19,7 +19,7 @@
mastodon-cpp -  0.18.4 +  0.18.8
diff --git a/docs/card_8hpp_source.html b/docs/card_8hpp_source.html index 582f65d..9115848 100644 --- a/docs/card_8hpp_source.html +++ b/docs/card_8hpp_source.html @@ -19,7 +19,7 @@
mastodon-cpp -  0.18.4 +  0.18.8
diff --git a/docs/classMastodon_1_1API-members.html b/docs/classMastodon_1_1API-members.html index f626de3..4370588 100644 --- a/docs/classMastodon_1_1API-members.html +++ b/docs/classMastodon_1_1API-members.html @@ -19,7 +19,7 @@
mastodon-cpp -  0.18.4 +  0.18.8
diff --git a/docs/classMastodon_1_1API.html b/docs/classMastodon_1_1API.html index 6ca2640..a8c98ce 100644 --- a/docs/classMastodon_1_1API.html +++ b/docs/classMastodon_1_1API.html @@ -19,7 +19,7 @@
mastodon-cpp -  0.18.4 +  0.18.8
@@ -310,8 +310,10 @@ Error codes 15 Network error (curlpp exception) -100 - 999 HTTP status codes +16 Timeout +100 - 999 HTTP status codes + 65535 Unknown error
Since
before 0.11.0
@@ -358,7 +360,7 @@ Error codes

A list of all v1 API calls.

The original / are substituted by _.

Since
before 0.11.0
-
198  {
199  accounts_id,
200  accounts_verify_credentials,
201  accounts_id_followers,
202  accounts_id_following,
203  accounts_id_statuses,
204  accounts_relationships,
205  accounts_search,
206  blocks,
207  domain_blocks,
208  favourites,
209  follow_requests,
210  instance,
211  custom_emojis,
212  lists,
213  accounts_id_lists,
214  lists_id_accounts,
215  lists_id,
216  mutes,
217  notifications,
218  notifications_id,
219  reports,
220  search,
221  statuses_id,
222  statuses_id_context,
223  statuses_id_card,
224  statuses_id_reblogged_by,
225  statuses_id_favourited_by,
226  timelines_home,
227  timelines_public,
228  timelines_tag_hashtag,
229  timelines_list_list_id,
230  // PATCH
231  accounts_update_credentials,
232  // POST
233  accounts_id_follow,
234  accounts_id_unfollow,
235  accounts_id_block,
236  accounts_id_unblock,
237  accounts_id_mute,
238  accounts_id_unmute,
239  apps,
240  follow_requests_id_authorize,
241  follow_requests_id_reject,
242  follows,
243  media,
244  notifications_clear,
245  notifications_dismiss,
246  statuses,
247  statuses_id_reblog,
248  statuses_id_unreblog,
249  statuses_id_favourite,
250  statuses_id_unfavourite,
251  statuses_id_pin,
252  statuses_id_unpin,
253  statuses_id_mute,
254  statuses_id_unmute,
255  // PUT
256  media_id,
257  // Streaming
258  streaming_user,
259  streaming_public,
260  streaming_public_local,
261  streaming_hashtag,
262  streaming_list,
263  // Push
264  push_subscription
265  };
+
199  {
200  accounts_id,
201  accounts_verify_credentials,
202  accounts_id_followers,
203  accounts_id_following,
204  accounts_id_statuses,
205  accounts_relationships,
206  accounts_search,
207  blocks,
208  domain_blocks,
209  favourites,
210  follow_requests,
211  instance,
212  custom_emojis,
213  lists,
214  accounts_id_lists,
215  lists_id_accounts,
216  lists_id,
217  mutes,
218  notifications,
219  notifications_id,
220  reports,
221  search,
222  statuses_id,
223  statuses_id_context,
224  statuses_id_card,
225  statuses_id_reblogged_by,
226  statuses_id_favourited_by,
227  timelines_home,
228  timelines_public,
229  timelines_tag_hashtag,
230  timelines_list_list_id,
231  // PATCH
232  accounts_update_credentials,
233  // POST
234  accounts_id_follow,
235  accounts_id_unfollow,
236  accounts_id_block,
237  accounts_id_unblock,
238  accounts_id_mute,
239  accounts_id_unmute,
240  apps,
241  follow_requests_id_authorize,
242  follow_requests_id_reject,
243  follows,
244  media,
245  notifications_clear,
246  notifications_dismiss,
247  statuses,
248  statuses_id_reblog,
249  statuses_id_unreblog,
250  statuses_id_favourite,
251  statuses_id_unfavourite,
252  statuses_id_pin,
253  statuses_id_unpin,
254  statuses_id_mute,
255  statuses_id_unmute,
256  // PUT
257  media_id,
258  // Streaming
259  streaming_user,
260  streaming_public,
261  streaming_public_local,
262  streaming_hashtag,
263  streaming_list,
264  // Push
265  push_subscription
266  };
@@ -384,7 +386,7 @@ Error codes

A list of all v2 API calls.

The original / are substituted by _.

Since
0.16.0
-
275  {
276  search
277  };
+
276  {
277  search
278  };

Constructor & Destructor Documentation

@@ -590,7 +592,7 @@ Error codes
Returns
Error code.
Since
before 0.11.0
Examples:
example01_dump_json.cpp, example02_parse_account.cpp, example03_mastocron.cpp, example07_register_app.cpp, example08_rate_limiting.cpp, and example15_proxy.cpp.
-
202 {
203  const parametermap p;
204  return get(call, p, answer);
205 }
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:188
+
202 {
203  const parametermap p;
204  return get(call, p, answer);
205 }
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:189
@@ -637,7 +639,7 @@ Error codes
Returns
Error code. If the URL has permanently changed, 13 is returned and answer is set to the new URL.
26 {
27  string strcall = "";
28  string strid = "";
29 
30  // The ID is part of the path
31  const auto &it = parameters.find("id");
32  if (it != parameters.end())
33  {
34  strid = it->second[0];
35  }
36 
37  switch (call)
38  {
39  case v1::accounts_verify_credentials:
40  strcall = "/api/v1/accounts/verify_credentials";
41  break;
42  case v1::blocks:
43  strcall = "/api/v1/blocks";
44  break;
45  case v1::domain_blocks:
46  strcall = "/api/v1/domain_blocks";
47  break;
48  case v1::favourites:
49  strcall = "/api/v1/favourites";
50  break;
51  case v1::follow_requests:
52  strcall = "/api/v1/follow_requests";
53  break;
54  case v1::instance:
55  strcall = "/api/v1/instance";
56  break;
57  case v1::custom_emojis:
58  strcall = "/api/v1/custom_emojis";
59  break;
60  case v1::lists:
61  strcall = "/api/v1/lists";
62  break;
63  case v1::mutes:
64  strcall = "/api/v1/mutes";
65  break;
66  case v1::notifications:
67  strcall = "/api/v1/notifications";
68  break;
69  case v1::reports:
70  strcall = "/api/v1/reports";
71  break;
72  case v1::timelines_home:
73  strcall = "/api/v1/timelines/home";
74  break;
75  case v1::timelines_public:
76  strcall = "/api/v1/timelines/public";
77  break;
78  case v1::accounts_relationships:
79  strcall = "/api/v1/accounts/relationships";
80  break;
81  case v1::accounts_id:
82  strcall = "/api/v1/accounts/" + strid;
83  break;
84  case v1::accounts_id_followers:
85  strcall = "/api/v1/accounts/" + strid + "/followers";
86  break;
87  case v1::accounts_id_following:
88  strcall = "/api/v1/accounts/" + strid + "/following";
89  break;
90  case v1::accounts_id_statuses:
91  strcall = "/api/v1/accounts/" + strid + "/statuses";
92  break;
93  case v1::accounts_search:
94  strcall = "/api/v1/accounts/search";
95  break;
96  case v1::accounts_id_lists:
97  strcall = "/api/v1/accounts/" + strid + "/lists";
98  break;
99  case v1::lists_id_accounts:
100  strcall = "/api/v1/lists/" + strid + "/accounts";
101  break;
102  case v1::lists_id:
103  strcall = "/api/v1/lists/" + strid;
104  break;
105  case v1::notifications_id:
106  strcall = "/api/v1/notifications/" + strid;
107  break;
108  case v1::search:
109  strcall = "/api/v1/search";
110  break;
111  case v1::statuses_id:
112  strcall = "/api/v1/statuses/" + strid;
113  break;
114  case v1::statuses_id_context:
115  strcall = "/api/v1/statuses/" + strid + "/context";
116  break;
117  case v1::statuses_id_card:
118  strcall = "/api/v1/statuses/" + strid + "/card";
119  break;
120  case v1::statuses_id_reblogged_by:
121  strcall = "/api/v1/statuses/" + strid + "/reblogged_by";
122  break;
123  case v1::statuses_id_favourited_by:
124  strcall = "/api/v1/statuses/" + strid + "/favourited_by";
125  break;
126  case v1::timelines_tag_hashtag:
127  {
128  // The hashtag is part of the path
129  const auto &it = parameters.find("hashtag");
130  if (it != parameters.end())
131  {
132  strcall = "/api/v1/timelines/tag/" + urlencode(it->second[0]);
133  }
134  else
135  {
136  ttdebug << "ERROR: Invalid call.\n";
137  return 11;
138  }
139  }
140  break;
141  case v1::timelines_list_list_id:
142  strcall = "/api/v1/timelines/list/" + strid;
143  break;
144  case v1::push_subscription:
145  strcall = "/api/v1/push/subscription";
146  break;
147  default:
148  ttdebug << "ERROR: Invalid call.\n";
149  return 11;
150  break;
151  }
152 
153  if (parameters.size() > 0)
154  {
155  // Delete the parameters that are already in strcall
156  parametermap newparameters = parameters;
157  newparameters.erase("id");
158  newparameters.erase("hashtag");
159  strcall += maptostr(newparameters);
160  }
161 
162  return get(strcall, answer);
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
-
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:188
+
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:189
@@ -675,7 +677,7 @@ Error codes

Make a GET request which requires parameters.

Since
0.16.0
-
167 {
168  string strcall = "";
169  string strid = "";
170 
171  // The ID is part of the path
172  const auto &it = parameters.find("id");
173  if (it != parameters.end())
174  {
175  strid = it->second[0];
176  }
177 
178  switch (call)
179  {
180  case v2::search:
181  strcall = "/api/v2/search";
182  break;
183  default:
184  ttdebug << "ERROR: Invalid call.\n";
185  return 11;
186  break;
187  }
188 
189  if (parameters.size() > 0)
190  {
191  // Delete the parameters that are already in strcall
192  parametermap newparameters = parameters;
193  newparameters.erase("id");
194  newparameters.erase("hashtag");
195  strcall += maptostr(newparameters);
196  }
197 
198  return get(strcall, answer);
199 }
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:188
+
167 {
168  string strcall = "";
169  string strid = "";
170 
171  // The ID is part of the path
172  const auto &it = parameters.find("id");
173  if (it != parameters.end())
174  {
175  strid = it->second[0];
176  }
177 
178  switch (call)
179  {
180  case v2::search:
181  strcall = "/api/v2/search";
182  break;
183  default:
184  ttdebug << "ERROR: Invalid call.\n";
185  return 11;
186  break;
187  }
188 
189  if (parameters.size() > 0)
190  {
191  // Delete the parameters that are already in strcall
192  parametermap newparameters = parameters;
193  newparameters.erase("id");
194  newparameters.erase("hashtag");
195  strcall += maptostr(newparameters);
196  }
197 
198  return get(strcall, answer);
199 }
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:189
@@ -744,7 +746,7 @@ Error codes
Returns
The header, or "" on error.
Since
before 0.11.0
Examples:
example08_rate_limiting.cpp.
-
263 {
264  string headers;
265  _http.get_headers(headers);
266  size_t startpos = headers.find(header + ':');
267  if (startpos != std::string::npos)
268  {
269  startpos = headers.find(':', startpos) + 2;
270  size_t endpos = headers.find("\r\n", startpos);
271  return headers.substr(startpos, endpos - startpos);
272  }
273 
274  return "";
275 }
const void get_headers(string &headers) const
Get all headers in a string.
Definition: http.cpp:189
+
263 {
264  string headers;
265  _http.get_headers(headers);
266  size_t startpos = headers.find(header + ':');
267  if (startpos != std::string::npos)
268  {
269  startpos = headers.find(':', startpos) + 2;
270  size_t endpos = headers.find("\r\n", startpos);
271  return headers.substr(startpos, endpos - startpos);
272  }
273 
274  return "";
275 }
const void get_headers(string &headers) const
Get all headers in a string.
Definition: http.cpp:197
@@ -906,7 +908,7 @@ Error codes
Returns
Error code. If the URL has permanently changed, 13 is returned and answer is set to the new URL.
Since
before 0.11.0
65 {
66  parametermap p = {};
67  return get_stream(call, p, answer, ptr);
68 }
const uint_fast16_t get_stream(const Mastodon::API::v1 &call, const parametermap &parameters, string &answer, std::unique_ptr< Mastodon::API::http > &ptr)
Make a streaming GET request.
Definition: get_stream.cpp:24
-
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:188
+
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:189
@@ -1063,7 +1065,7 @@ Error codes
Since
before 0.11.0
Examples:
example05_follow_unfollow.cpp, example06_toot_delete-toot.cpp, example10_simplify.cpp, and example11_post_media.cpp.
129 {
130  const parametermap p;
131  return post(call, p, answer);
132 }
const uint_fast16_t post(const Mastodon::API::v1 &call, string &answer)
Make a POST request which doesn&#39;t require parameters.
Definition: post.cpp:128
-
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:188
+
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:189
@@ -1329,7 +1331,7 @@ Error codes
Examples:
example07_register_app.cpp.
170 {
171  API::parametermap parameters =
172  {
173  { "client_name", { client_name } },
174  { "redirect_uris", { redirect_uri } },
175  { "scopes", { scopes } },
176  { "website", { website } }
177  };
178 
179  string answer;
180  uint_fast16_t ret = post(API::v1::apps, parameters, answer);
181 
182  if (ret == 0)
183  {
184  std::smatch match;
185  std::regex reid("client_id\":\"([0-9a-fA-F]+)\"");
186  std::regex resecret("client_secret\":\"([0-9a-fA-F]+)\"");
187 
188  std::regex_search(answer, match, reid);
189  client_id = match[1].str();
190  std::regex_search(answer, match, resecret);
191  client_secret = match[1].str();
192 
193  url = "https://" + _instance + "/oauth/authorize" +
194  "?scope=" + urlencode(scopes) + "&response_type=code" +
195  "&redirect_uri=" + urlencode(redirect_uri) +
196  "&client_id=" + client_id;
197  if (!website.empty())
198  {
199  url += "&website=" + urlencode(website);
200  }
201 
202  return 0;
203  }
204  else if (ret == 13)
205  {
206  url = answer;
207  return ret;
208  }
209  else
210  {
211  std::cerr << "Error code: " << ret << '\n';
212  return ret;
213  }
214 
215 }
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
const uint_fast16_t post(const Mastodon::API::v1 &call, string &answer)
Make a POST request which doesn&#39;t require parameters.
Definition: post.cpp:128
-
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:188
+
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:189
@@ -1395,7 +1397,7 @@ Error codes
Since
before 0.11.0
Examples:
example07_register_app.cpp.
232 {
233  API::parametermap parameters =
234  {
235  { "client_id", { client_id } },
236  { "client_secret", { client_secret } },
237  { "grant_type", { "authorization_code" } },
238  { "redirect_uri", { redirect_uri } },
239  { "code", { code } },
240  };
241 
242  std::string answer;
243  uint_fast16_t ret = post("/oauth/token", parameters, answer);
244  if (ret == 0)
245  {
246  std::smatch match;
247  std::regex retoken("access_token\":\"([0-9a-fA-F]+)\"");
248 
249  std::regex_search(answer, match, retoken);
250  access_token = match[1].str();
251  _access_token = access_token;
252 
253  return 0;
254  }
255  else
256  {
257  std::cerr << "Error code: " << ret << '\n';
258  return ret;
259  }
260 }
const uint_fast16_t post(const Mastodon::API::v1 &call, string &answer)
Make a POST request which doesn&#39;t require parameters.
Definition: post.cpp:128
-
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:188
+
std::map< string, std::vector< string > > parametermap
Used for passing parameters.
Definition: mastodon-cpp.hpp:189
diff --git a/docs/classMastodon_1_1API_1_1http-members.html b/docs/classMastodon_1_1API_1_1http-members.html index 25fd39b..82aa146 100644 --- a/docs/classMastodon_1_1API_1_1http-members.html +++ b/docs/classMastodon_1_1API_1_1http-members.html @@ -19,7 +19,7 @@
mastodon-cpp -  0.18.4 +  0.18.8
diff --git a/docs/classMastodon_1_1API_1_1http.html b/docs/classMastodon_1_1API_1_1http.html index 80d1ea6..29f370f 100644 --- a/docs/classMastodon_1_1API_1_1http.html +++ b/docs/classMastodon_1_1API_1_1http.html @@ -19,7 +19,7 @@
mastodon-cpp -  0.18.4 +  0.18.8
@@ -119,7 +119,7 @@ const void abort_streamCancels the stream. Use only with streams.

Cancels the stream next time data comes in. Can take a few seconds. This works only with streams, because only streams have an own http object.

Since
0.12.2
-
221 {
222  _cancel_stream = true;
223 }
+
229 {
230  _cancel_stream = true;
231 }
@@ -141,7 +141,7 @@ const void abort_streamThe mutex guards the function that writes to the string you specified in get_stream().

Returns
A reference of the mutex.
Since
0.12.3
-
231 {
232  return _mutex;
233 }
+
239 {
240  return _mutex;
241 }
@@ -194,7 +194,7 @@ const void abort_stream
Returns
Error code. If the URL has permanently changed, 13 is returned and answer is set to the new URL.
Since
before 0.11.0
-
58 {
59  using namespace std::placeholders; // _1, _2, _3
60 
61  uint_fast16_t ret = 0;
62  ttdebug << "Path is: " << path << '\n';
63 
64  try
65  {
66  curlpp::Easy request;
67  std::list<string> headers;
68 
69  request.setOpt<curlopts::Url>("https://" + _instance + path);
70  ttdebug << "User-Agent: " << parent.get_useragent() << "\n";
71  request.setOpt<curlopts::UserAgent>(parent.get_useragent());
72 
73  {
74  string proxy;
75  string userpw;
76  parent.get_proxy(proxy, userpw);
77  if (!proxy.empty())
78  {
79  request.setOpt<curlopts::Proxy>(proxy);
80  if (!userpw.empty())
81  {
82  request.setOpt<curlopts::ProxyUserPwd>(userpw);
83  }
84  }
85  }
86 
87  if (!_access_token.empty())
88  {
89  headers.push_back("Authorization: Bearer " + _access_token);
90  }
91  if (meth != http::method::GET_STREAM)
92  {
93  headers.push_back("Connection: close");
94  // Get headers from server
95  request.setOpt<curlpp::options::Header>(true);
96  }
97 
98  request.setOpt<curlopts::HttpHeader>(headers);
99  request.setOpt<curlopts::FollowLocation>(true);
100  request.setOpt<curlopts::WriteFunction>
101  (std::bind(&http::callback_write, this, _1, _2, _3, &answer));
102  request.setOpt<curlopts::ProgressFunction>
103  (std::bind(&http::callback_progress, this, _1, _2, _3, _4));
104  request.setOpt<curlopts::NoProgress>(0);
105  if (!formdata.empty())
106  {
107  request.setOpt<curlopts::HttpPost>(formdata);
108  }
109 
110  switch (meth)
111  {
112  case http::method::GET:
113  break;
114  case http::method::PATCH:
115  request.setOpt<curlopts::CustomRequest>("PATCH");
116  break;
117  case http::method::POST:
118  request.setOpt<curlopts::CustomRequest>("POST");
119  break;
120  case http::method::PUT:
121  request.setOpt<curlopts::CustomRequest>("PUT");
122  case http::method::DELETE:
123  request.setOpt<curlopts::CustomRequest>("DELETE");
124  default:
125  break;
126  }
127 
128  //request.setOpt<curlopts::Verbose>(true);
129 
130  answer.clear();
131  request.perform();
132  ret = curlpp::infos::ResponseCode::get(request);
133  ttdebug << "Response code: " << ret << '\n';
134  // Work around "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK"
135  size_t pos = answer.find("\r\n\r\n", 25);
136  _headers = answer.substr(0, pos);
137  // Only return body
138  answer = answer.substr(pos + 4);
139 
140  if (ret == 200 || ret == 302 || ret == 307)
141  { // OK or Found or Temporary Redirect
142  return 0;
143  }
144  else if (ret == 301 || ret == 308)
145  { // Moved Permanently or Permanent Redirect
146  // return new URL
147  answer = curlpp::infos::EffectiveUrl::get(request);
148  return 13;
149  }
150  else
151  {
152  return ret;
153  }
154  }
155  catch (curlpp::RuntimeError &e)
156  {
157  // This error is thrown if http.cancel_stream() is used.
158  if ((std::strncmp(e.what(), "Callback aborted", 16) == 0) ||
159  (std::strncmp(e.what(), "Failed writing body", 19) == 0))
160  {
161  ttdebug << "Request was cancelled by user\n";
162  return 14;
163  }
164 
165  if (parent.exceptions())
166  {
167  std::rethrow_exception(std::current_exception());
168  }
169  else
170  {
171  ttdebug << "curlpp::RuntimeError: " << e.what() << std::endl;
172  return 15;
173  }
174  }
175  catch (curlpp::LogicError &e)
176  {
177  if (parent.exceptions())
178  {
179  std::rethrow_exception(std::current_exception());
180  }
181 
182  ttdebug << "curlpp::LogicError: " << e.what() << std::endl;
183  return 15;
184  }
185 
186  return ret;
187 }
+
58 {
59  using namespace std::placeholders; // _1, _2, _3
60 
61  uint_fast16_t ret = 0;
62  ttdebug << "Path is: " << path << '\n';
63 
64  try
65  {
66  curlpp::Easy request;
67  std::list<string> headers;
68 
69  request.setOpt<curlopts::Url>("https://" + _instance + path);
70  ttdebug << "User-Agent: " << parent.get_useragent() << "\n";
71  request.setOpt<curlopts::UserAgent>(parent.get_useragent());
72 
73  {
74  string proxy;
75  string userpw;
76  parent.get_proxy(proxy, userpw);
77  if (!proxy.empty())
78  {
79  request.setOpt<curlopts::Proxy>(proxy);
80  if (!userpw.empty())
81  {
82  request.setOpt<curlopts::ProxyUserPwd>(userpw);
83  }
84  }
85  }
86 
87  if (!_access_token.empty())
88  {
89  headers.push_back("Authorization: Bearer " + _access_token);
90  }
91  if (meth != http::method::GET_STREAM)
92  {
93  headers.push_back("Connection: close");
94  // Get headers from server
95  request.setOpt<curlpp::options::Header>(true);
96  }
97 
98  request.setOpt<curlopts::HttpHeader>(headers);
99  request.setOpt<curlopts::FollowLocation>(true);
100  request.setOpt<curlopts::WriteFunction>
101  (std::bind(&http::callback_write, this, _1, _2, _3, &answer));
102  request.setOpt<curlopts::ProgressFunction>
103  (std::bind(&http::callback_progress, this, _1, _2, _3, _4));
104  request.setOpt<curlopts::NoProgress>(0);
105  if (!formdata.empty())
106  {
107  request.setOpt<curlopts::HttpPost>(formdata);
108  }
109 
110  switch (meth)
111  {
112  case http::method::GET:
113  break;
114  case http::method::PATCH:
115  request.setOpt<curlopts::CustomRequest>("PATCH");
116  break;
117  case http::method::POST:
118  request.setOpt<curlopts::CustomRequest>("POST");
119  break;
120  case http::method::PUT:
121  request.setOpt<curlopts::CustomRequest>("PUT");
122  case http::method::DELETE:
123  request.setOpt<curlopts::CustomRequest>("DELETE");
124  default:
125  break;
126  }
127 
128  //request.setOpt<curlopts::Verbose>(true);
129 
130  answer.clear();
131  request.perform();
132  ret = curlpp::infos::ResponseCode::get(request);
133  ttdebug << "Response code: " << ret << '\n';
134  // Work around "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK"
135  size_t pos = answer.find("\r\n\r\n", 25);
136  _headers = answer.substr(0, pos);
137  // Only return body
138  answer = answer.substr(pos + 4);
139 
140  if (ret == 200 || ret == 302 || ret == 307)
141  { // OK or Found or Temporary Redirect
142  return 0;
143  }
144  else if (ret == 301 || ret == 308)
145  { // Moved Permanently or Permanent Redirect
146  // return new URL
147  answer = curlpp::infos::EffectiveUrl::get(request);
148  return 13;
149  }
150  else if (ret == 0)
151  {
152  return 0xffff;
153  }
154  else
155  {
156  return ret;
157  }
158  }
159  catch (curlpp::RuntimeError &e)
160  {
161  const string what = e.what();
162  // This error is thrown if http.cancel_stream() is used.
163  if ((what.compare(0, 16, "Callback aborted") == 0) ||
164  (what.compare(0, 19, "Failed writing body") == 0))
165  {
166  ttdebug << "Request was cancelled by user\n";
167  return 14;
168  }
169  else if (what.compare(what.size() - 20, 20, "Connection timed out") == 0)
170  {
171  ttdebug << "Timeout\n";
172  return 16;
173  }
174 
175  if (parent.exceptions())
176  {
177  std::rethrow_exception(std::current_exception());
178  }
179  else
180  {
181  ttdebug << "curlpp::RuntimeError: " << e.what() << std::endl;
182  return 15;
183  }
184  }
185  catch (curlpp::LogicError &e)
186  {
187  if (parent.exceptions())
188  {
189  std::rethrow_exception(std::current_exception());
190  }
191 
192  ttdebug << "curlpp::LogicError: " << e.what() << std::endl;
193  return 15;
194  }
195 }

The documentation for this class was generated from the following files: diff --git a/docs/functions_func_m.html b/docs/functions_func_m.html index ccc9a3b..5e3bb20 100644 --- a/docs/functions_func_m.html +++ b/docs/functions_func_m.html @@ -19,7 +19,7 @@
mastodon-cpp -  0.18.4 +  0.18.8
diff --git a/docs/functions_func_n.html b/docs/functions_func_n.html index 000096b..e07412a 100644 --- a/docs/functions_func_n.html +++ b/docs/functions_func_n.html @@ -19,7 +19,7 @@
mastodon-cpp -  0.18.4 +  0.18.8
@@ -51,12 +51,13 @@ $(function() {
  • note() : Mastodon::Easy::Account +, Mastodon::Easy::Account::Source
  • note_plain() : Mastodon::Easy::Account
  • Notification() -: Mastodon::Easy::Notification +: Mastodon::Easy::Notification
  • diff --git a/docs/functions_func_p.html b/docs/functions_func_p.html index 5e20d62..c1b88cb 100644 --- a/docs/functions_func_p.html +++ b/docs/functions_func_p.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -62,6 +62,7 @@ $(function() {
  • privacy() : Mastodon::Easy::Account +, Mastodon::Easy::Account::Source
  • provider_name() : Mastodon::Easy::Card @@ -70,7 +71,7 @@ $(function() { : Mastodon::Easy::Card
  • PushSubscription() -: Mastodon::Easy::PushSubscription +: Mastodon::Easy::PushSubscription
  • put() : Mastodon::API diff --git a/docs/functions_func_r.html b/docs/functions_func_r.html index bc2946a..c4c9f0f 100644 --- a/docs/functions_func_r.html +++ b/docs/functions_func_r.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_func_s.html b/docs/functions_func_s.html index e6a43f3..e552a27 100644 --- a/docs/functions_func_s.html +++ b/docs/functions_func_s.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -46,14 +46,15 @@ $(function() { : Mastodon::Easy::PushSubscription
  • send_post() -: Mastodon::Easy +: Mastodon::Easy
  • send_toot() -: Mastodon::Easy +: Mastodon::Easy
  • sensitive() : Mastodon::Easy::Account -, Mastodon::Easy::Status +, Mastodon::Easy::Account::Source +, Mastodon::Easy::Status
  • server_key() : Mastodon::Easy::PushSubscription @@ -79,6 +80,9 @@ $(function() {
  • size_small() : Mastodon::Easy::Attachment
  • +
  • Source() +: Mastodon::Easy::Account::Source +
  • spoiler_text() : Mastodon::Easy::Status
  • @@ -89,7 +93,7 @@ $(function() { : Mastodon::Easy::Notification
  • Status() -: Mastodon::Easy::Status +: Mastodon::Easy::Status
  • statuses() : Mastodon::Easy::Results diff --git a/docs/functions_func_t.html b/docs/functions_func_t.html index 4db9734..32617de 100644 --- a/docs/functions_func_t.html +++ b/docs/functions_func_t.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_func_u.html b/docs/functions_func_u.html index a033219..84ad89b 100644 --- a/docs/functions_func_u.html +++ b/docs/functions_func_u.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_func_v.html b/docs/functions_func_v.html index 1b7034d..89e944d 100644 --- a/docs/functions_func_v.html +++ b/docs/functions_func_v.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -43,7 +43,8 @@ $(function() {

    - v -

    diff --git a/docs/functions_func_w.html b/docs/functions_func_w.html index 067b777..f23082b 100644 --- a/docs/functions_func_w.html +++ b/docs/functions_func_w.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_g.html b/docs/functions_g.html index fd377a6..53fd91d 100644 --- a/docs/functions_g.html +++ b/docs/functions_g.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_h.html b/docs/functions_h.html index 7877ba7..18d0c5f 100644 --- a/docs/functions_h.html +++ b/docs/functions_h.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -71,7 +71,7 @@ $(function() { : Mastodon::Easy::Tag
  • History() -: Mastodon::Easy::Tag::History +: Mastodon::Easy::Tag::History
  • html() : Mastodon::Easy::Card diff --git a/docs/functions_i.html b/docs/functions_i.html index bfee668..3f28cd4 100644 --- a/docs/functions_i.html +++ b/docs/functions_i.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_j.html b/docs/functions_j.html index f44de94..0593131 100644 --- a/docs/functions_j.html +++ b/docs/functions_j.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_l.html b/docs/functions_l.html index f5a9001..5271a8a 100644 --- a/docs/functions_l.html +++ b/docs/functions_l.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -55,7 +55,7 @@ $(function() { : Mastodon::Easy::List
  • locked() -: Mastodon::Easy::Account +: Mastodon::Easy::Account
  • diff --git a/docs/functions_m.html b/docs/functions_m.html index 0ab967e..7a7264c 100644 --- a/docs/functions_m.html +++ b/docs/functions_m.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_n.html b/docs/functions_n.html index 986f26a..b4d10bc 100644 --- a/docs/functions_n.html +++ b/docs/functions_n.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -51,6 +51,7 @@ $(function() {
  • note() : Mastodon::Easy::Account +, Mastodon::Easy::Account::Source
  • note_plain() : Mastodon::Easy::Account diff --git a/docs/functions_p.html b/docs/functions_p.html index 0240491..14437ee 100644 --- a/docs/functions_p.html +++ b/docs/functions_p.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -65,6 +65,7 @@ $(function() {
  • privacy() : Mastodon::Easy::Account +, Mastodon::Easy::Account::Source
  • provider_name() : Mastodon::Easy::Card diff --git a/docs/functions_r.html b/docs/functions_r.html index 6367cbe..3fa8b4e 100644 --- a/docs/functions_r.html +++ b/docs/functions_r.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_s.html b/docs/functions_s.html index ada6c5b..5173e9e 100644 --- a/docs/functions_s.html +++ b/docs/functions_s.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -46,14 +46,15 @@ $(function() { : Mastodon::Easy::PushSubscription
  • send_post() -: Mastodon::Easy +: Mastodon::Easy
  • send_toot() -: Mastodon::Easy +: Mastodon::Easy
  • sensitive() : Mastodon::Easy::Account -, Mastodon::Easy::Status +, Mastodon::Easy::Account::Source +, Mastodon::Easy::Status
  • server_key() : Mastodon::Easy::PushSubscription @@ -79,6 +80,9 @@ $(function() {
  • size_small() : Mastodon::Easy::Attachment
  • +
  • Source() +: Mastodon::Easy::Account::Source +
  • spoiler_text() : Mastodon::Easy::Status
  • diff --git a/docs/functions_t.html b/docs/functions_t.html index 3ab9f37..f44646f 100644 --- a/docs/functions_t.html +++ b/docs/functions_t.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_type.html b/docs/functions_type.html index ef32d6d..50fa508 100644 --- a/docs/functions_type.html +++ b/docs/functions_type.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_u.html b/docs/functions_u.html index 0eb6071..e5de27b 100644 --- a/docs/functions_u.html +++ b/docs/functions_u.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/functions_v.html b/docs/functions_v.html index e85ec47..4642c41 100644 --- a/docs/functions_v.html +++ b/docs/functions_v.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -49,7 +49,8 @@ $(function() { : Mastodon::API
  • valid() -: Mastodon::Easy::Account +: Mastodon::Easy::Account::Source +, Mastodon::Easy::Account , Mastodon::Easy::Application , Mastodon::Easy::Attachment , Mastodon::Easy::Card @@ -72,7 +73,7 @@ $(function() { : Mastodon::Easy::Instance
  • visibility() -: Mastodon::Easy::Status +: Mastodon::Easy::Status
  • visibility_type : Mastodon::Easy diff --git a/docs/functions_w.html b/docs/functions_w.html index 00de21e..0755054 100644 --- a/docs/functions_w.html +++ b/docs/functions_w.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/hierarchy.html b/docs/hierarchy.html index 0994127..4037005 100644 --- a/docs/hierarchy.html +++ b/docs/hierarchy.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -49,24 +49,25 @@ $(function() {  CMastodon::EasyChild of Mastodon::API with abstract methods  CMastodon::Easy::EntityBase class for all entities  CMastodon::Easy::AccountClass to hold accounts - CMastodon::Easy::ApplicationClass to hold applications - CMastodon::Easy::AttachmentClass to hold attachments - CMastodon::Easy::CardClass to hold cards - CMastodon::Easy::ContextClass to hold contexts - CMastodon::Easy::EmojiClass to hold emojis - CMastodon::Easy::InstanceClass to hold instances - CMastodon::Easy::ListClass to hold lists - CMastodon::Easy::MentionClass to hold mentions - CMastodon::Easy::NotificationClass to hold notifications - CMastodon::Easy::PushSubscriptionClass to hold push subscriptions - CMastodon::Easy::RelationshipClass to hold relationships - CMastodon::Easy::ReportClass to hold reports - CMastodon::Easy::ResultsClass to hold results - CMastodon::Easy::StatusClass to hold statuses - CMastodon::Easy::TagClass to hold tags - CMastodon::Easy::Tag::HistoryClass to hold Tag history - CMastodon::API::httpHttp class. Do not use this directly - CMastodon::Easy::LinkClass to hold the Link-header + CMastodon::Easy::Account::SourceClass to hold source attribute + CMastodon::Easy::ApplicationClass to hold applications + CMastodon::Easy::AttachmentClass to hold attachments + CMastodon::Easy::CardClass to hold cards + CMastodon::Easy::ContextClass to hold contexts + CMastodon::Easy::EmojiClass to hold emojis + CMastodon::Easy::InstanceClass to hold instances + CMastodon::Easy::ListClass to hold lists + CMastodon::Easy::MentionClass to hold mentions + CMastodon::Easy::NotificationClass to hold notifications + CMastodon::Easy::PushSubscriptionClass to hold push subscriptions + CMastodon::Easy::RelationshipClass to hold relationships + CMastodon::Easy::ReportClass to hold reports + CMastodon::Easy::ResultsClass to hold results + CMastodon::Easy::StatusClass to hold statuses + CMastodon::Easy::TagClass to hold tags + CMastodon::Easy::Tag::HistoryClass to hold Tag history + CMastodon::API::httpHttp class. Do not use this directly + CMastodon::Easy::LinkClass to hold the Link-header diff --git a/docs/index.html b/docs/index.html index 0450897..ddb4f21 100644 --- a/docs/index.html +++ b/docs/index.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -47,19 +47,6 @@ $(function() {

    TODO-list

    Usage

    The HTML reference can be generated with build_doc.sh, if doxygen is installed. It is also available at doc.schlomp.space/mastodon-cpp/. There are examples in examples/.

    -

    Upgrading from below 0.13.0

    -
      -
    • You have to recompile all applications linking against this library.
    • -
    • We use a mutex now to guard the string that is being written to. You can get a reference to it with Mastodon::API::http::get_mutex() (see examples 9 and 13 for more info). This is only relevant for streams.
    • -
    -

    Upgrading from below 0.10.0

    -

    Mastodon::API::get, ::get_stream, ::post, ::put and ::del don't take std::string as parameter to API-calls anymore, only parametermaps. The old behaviour is still supported but is deprecated and will be removed in version 1.0.0.

    -

    Upgrading from below 0.7.0

    -

    Your projects will break, sorry. Here are the important changes:

    -
      -
    • The header location has changed. They are now in mastodon-cpp/.
    • -
    • Specific network error messages have been replaced by 15, "Network error". You can get the exceptions from curlpp with Mastodon::API::exceptions(true).
    • -

    Most basic example

    {C++}
    #include <iostream>
    #include <string>
    #include <mastodon-cpp/mastodon-cpp.hpp>
    int main()
    {
    Mastodon::API masto("social.example.com", "auth_token");
    std::string answer;
    masto.get(Mastodon::API::v1::accounts_verify_credentials, answer);
    std::cout << answer << '\n';
    }

    Another simple example

    Using the Easy-class.

    @@ -83,11 +70,13 @@ $(function() { 15 Network error (curlpp exception) -100 - 999 HTTP status codes +16 Timeout +100 - 999 HTTP status codes + 65535 Unknown error -

    If you use a debug build, you get more verbose error messages. Errors 20-25 are no longer in use (since 0.8.9).

    +

    If you use a debug build, you get more verbose error messages.

    Useful links

    • https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md "Mastodon API reference"
    • @@ -95,27 +84,26 @@ $(function() {

    Install

    Packages

    -

    Every release includes packages for the package managers of Gentoo, Debian and Red Hat.

    +

    Every release includes packages for the package managers of Debian and Red Hat. Gentoo packages are available in an overlay.

    Gentoo

    Add my repository and install it from there.

    -
    eselect repository enable tastytea
    echo 'dev-cpp/mastodon-cpp ~amd64' >> /etc/portage/package.keywords/mastodon-cpp
    emaint sync -r tastytea
    emerge -a dev-cpp/mastodon-cpp

    Or put the ebuild into your local overlay and run ebuild <ebuild path> manifest. Install with emerge mastodon-cpp.

    -

    DEB and RPM

    +
    eselect repository enable tastytea
    echo 'dev-cpp/mastodon-cpp ~amd64' >> /etc/portage/package.keywords/mastodon-cpp
    emaint sync -r tastytea
    emerge -a dev-cpp/mastodon-cpp

    DEB and RPM

    Prebuilt DEB and RPM packages for x86_64(amd64) are provided with each release. These packages are automatically built and not tested. Install with dpkg -i or rpm -i, respectively.

    -

    To use the DEB package on stretch, you will need libcurlpp0 from buster.

    +

    To use the DEB package on stretch, you will need libcurlpp0 from sid.

    From source

    Dependencies

    • Tested OS: Linux
    • -
    • C++ compiler (tested: gcc 6/7/8)
    • -
    • cmake (tested: 3.9 / 3.11)
    • +
    • C++ compiler (tested: gcc 6 / 7 / 8)
    • +
    • cmake (tested: 3.9 / 3.7)
    • pkgconfig (tested: 0.29)
    • -
    • libcurl (tested: 7.60 / 7.52)
    • -
    • curlpp (tested: 0.8 / 0.7)
    • +
    • libcurl (tested: 7.61 / 7.60)
    • +
    • curlpp (tested: 0.8)
    • Optional
      • Easy interface & Examples: jsoncpp (tested: 1.8 / 1.7)
      • Documentation: doxygen (tested: 1.8)
      • -
      • DEB package: dpkg (tested: 1.18)
      • -
      • RPM package: rpm (tested: 4.12)
      • +
      • DEB package: dpkg (tested: 1.19)
      • +
      • RPM package: rpm (tested: 4.14 / 4.11)
    @@ -130,14 +118,13 @@ $(function() {
  • -DWITHOUT_EASY=ON to not build the Easy abstractions and to get rid of the jsoncpp-dependency (not recommended)
  • -DWITH_EXAMPLES=ON if you want to compile the examples
  • -DWITH_TESTS=ON if you want to compile the tests
  • +
  • -DWITH_STATIC=ON If you want a static library along with the dynamic one
  • -DWITH_DOC=ON if you want to compile the HTML reference
  • -DWITH_DEB=ON if you want to be able to generate a deb-package
  • -DWITH_RPM=ON if you want to be able to generate an rpm-package
  • You can run the tests with ctest .. inside the build directory. To install, run make install.

    Packages

    -

    Gentoo

    -

    Put the ebuild from packages/gentoo into your local overlay and rename it to match the desired version or use the live-ebuild (mastodon-cpp-9999.ebuild) to install the development version.

    DEB and RPM

    Compile with -DWITH_DEB=ON or -DWITH_RPM=ON. Run make package from the build directory to generate a DEB/RPM package.

    Other

    diff --git a/docs/instance_8hpp_source.html b/docs/instance_8hpp_source.html index 0b04f59..a29586c 100644 --- a/docs/instance_8hpp_source.html +++ b/docs/instance_8hpp_source.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/list_8hpp_source.html b/docs/list_8hpp_source.html index fe627af..b85e9a8 100644 --- a/docs/list_8hpp_source.html +++ b/docs/list_8hpp_source.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/macros_8hpp_source.html b/docs/macros_8hpp_source.html index 3c75bc6..81a34ba 100644 --- a/docs/macros_8hpp_source.html +++ b/docs/macros_8hpp_source.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    diff --git a/docs/mastodon-cpp_8hpp_source.html b/docs/mastodon-cpp_8hpp_source.html index 95f65d9..b7f99ad 100644 --- a/docs/mastodon-cpp_8hpp_source.html +++ b/docs/mastodon-cpp_8hpp_source.html @@ -19,7 +19,7 @@
    mastodon-cpp -  0.18.4 +  0.18.8
    @@ -47,13 +47,13 @@ $(function() {
    mastodon-cpp.hpp
    -
    1 /* This file is part of mastodon-cpp.
    2  * Copyright © 2018 tastytea <tastytea@tastytea.de>
    3  *
    4  * This program is free software: you can redistribute it and/or modify
    5  * it under the terms of the GNU General Public License as published by
    6  * the Free Software Foundation, version 3.
    7  *
    8  * This program is distributed in the hope that it will be useful,
    9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    11  * GNU General Public License for more details.
    12  *
    13  * You should have received a copy of the GNU General Public License
    14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    15  */
    16 
    17 #ifndef MASTODON_CPP_HPP
    18 #define MASTODON_CPP_HPP
    19 
    20 #include <string>
    21 #include <vector>
    22 #include <cstdint>
    23 #include <map>
    24 #include <memory>
    25 #include <array>
    26 #include <mutex>
    27 #include <curlpp/cURLpp.hpp>
    28 #include <curlpp/Easy.hpp>
    29 
    30 using std::uint_fast16_t;
    31 using std::string;
    32 
    52 namespace Mastodon
    53 {
    76 class API
    77 {
    78 public:
    84  class http
    85  {
    86  public:
    90  enum class method
    91  {
    92  GET,
    93  PATCH,
    94  POST,
    95  PUT,
    96  DELETE,
    97  GET_STREAM
    98  };
    99 
    100  explicit http(const API &api, const string &instance,
    101  const string &access_token);
    102  ~http();
    103  const uint_fast16_t request(const method &meth,
    104  const string &path,
    105  string &answer);
    106 
    120  const uint_fast16_t request(const method &meth,
    121  const string &path,
    122  const curlpp::Forms &formdata,
    123  string &answer);
    124 
    128  const void get_headers(string &headers) const;
    129 
    140  const void cancel_stream();
    141 
    142  [[deprecated("Will vanish in 1.0.0. Use cancel_stream() instead.")]]
    143  const void abort_stream();
    144 
    155  std::mutex &get_mutex();
    156 
    157  private:
    158  const API &parent;
    159  const string _instance;
    160  const string _access_token;
    161  string _headers;
    162  bool _cancel_stream;
    163  std::mutex _mutex;
    164 
    165  const size_t callback_write(char* data, size_t size, size_t nmemb,
    166  string *oss);
    167  [[deprecated("Will vanish in 1.0.0. Use callback_write() instead.")]]
    168  const size_t callback(char* data, size_t size, size_t nmemb,
    169  string *oss);
    170  double callback_progress(double /* dltotal */, double /* dlnow */,
    171  double /* ultotal */, double /* ulnow */);
    172  };
    173 
    188  typedef std::map<string, std::vector<string>> parametermap;
    189 
    197  enum class v1
    198  {
    199  accounts_id,
    200  accounts_verify_credentials,
    201  accounts_id_followers,
    202  accounts_id_following,
    203  accounts_id_statuses,
    204  accounts_relationships,
    205  accounts_search,
    206  blocks,
    207  domain_blocks,
    208  favourites,
    209  follow_requests,
    210  instance,
    211  custom_emojis,
    212  lists,
    213  accounts_id_lists,
    214  lists_id_accounts,
    215  lists_id,
    216  mutes,
    217  notifications,
    218  notifications_id,
    219  reports,
    220  search,
    221  statuses_id,
    222  statuses_id_context,
    223  statuses_id_card,
    224  statuses_id_reblogged_by,
    225  statuses_id_favourited_by,
    226  timelines_home,
    227  timelines_public,
    228  timelines_tag_hashtag,
    229  timelines_list_list_id,
    230  // PATCH
    231  accounts_update_credentials,
    232  // POST
    233  accounts_id_follow,
    234  accounts_id_unfollow,
    235  accounts_id_block,
    236  accounts_id_unblock,
    237  accounts_id_mute,
    238  accounts_id_unmute,
    239  apps,
    240  follow_requests_id_authorize,
    241  follow_requests_id_reject,
    242  follows,
    243  media,
    244  notifications_clear,
    245  notifications_dismiss,
    246  statuses,
    247  statuses_id_reblog,
    248  statuses_id_unreblog,
    249  statuses_id_favourite,
    250  statuses_id_unfavourite,
    251  statuses_id_pin,
    252  statuses_id_unpin,
    253  statuses_id_mute,
    254  statuses_id_unmute,
    255  // PUT
    256  media_id,
    257  // Streaming
    258  streaming_user,
    259  streaming_public,
    260  streaming_public_local,
    261  streaming_hashtag,
    262  streaming_list,
    263  // Push
    264  push_subscription
    265  };
    266 
    274  enum class v2
    275  {
    276  search
    277  };
    278 
    290  explicit API(const string &instance, const string &access_token);
    291 
    299  const void set_useragent(const string &useragent);
    300 
    308  const string get_useragent() const;
    309 
    317  const string get_instance() const;
    318 
    336  static const string urlencode(const string &str);
    337 
    351  static const string urldecode(const string &str);
    352 
    370  const uint_fast16_t register_app1(const string &client_name,
    371  const string &redirect_uri,
    372  const string &scopes,
    373  const string &website,
    374  string &client_id,
    375  string &client_secret,
    376  string &url);
    377 
    378  [[deprecated("Will vanish in 1.0.0")]]
    379  const uint_fast16_t register_app1(const string &instance,
    380  const string &client_name,
    381  const string &redirect_uri,
    382  const string &scopes,
    383  const string &website,
    384  string &client_id,
    385  string &client_secret,
    386  string &url);
    387 
    403  const uint_fast16_t register_app2(const string &client_id,
    404  const string &client_secret,
    405  const string &redirect_uri,
    406  const string &code,
    407  string &access_token);
    408 
    409  [[deprecated("Will vanish in 1.0.0")]]
    410  const uint_fast16_t register_app2(const string &instance,
    411  const string &client_id,
    412  const string &client_secret,
    413  const string &redirect_uri,
    414  const string &code,
    415  string &access_token);
    416 
    426  const string get_header(const string &header) const;
    427 
    440  bool exceptions(const bool &value);
    441 
    445  const bool exceptions() const;
    446 
    454  static const string unescape_html(const string &html);
    455 
    467  const void set_proxy(const string &proxy, const string &userpw = "");
    468 
    477  const void get_proxy(string &proxy, string &userpw) const;
    478 
    490  const uint_fast16_t get(const Mastodon::API::v1 &call, string &answer);
    491 
    503  const uint_fast16_t get(const Mastodon::API::v1 &call,
    504  const parametermap &parameters,
    505  string &answer);
    506 
    512  const uint_fast16_t get(const Mastodon::API::v2 &call,
    513  const parametermap &parameters,
    514  string &answer);
    515 
    528  const uint_fast16_t get(const string &call, string &answer);
    529 
    530  [[deprecated("Will vanish in 1.0.0, use get() without string argument "
    531  "instead.")]]
    532  const uint_fast16_t get(const Mastodon::API::v1 &call,
    533  const string &argument,
    534  string &answer);
    535 
    536  [[deprecated("Will vanish in 1.0.0, use get() without string argument "
    537  "instead.")]]
    538  const uint_fast16_t get(const Mastodon::API::v1 &call,
    539  const string &argument,
    540  const parametermap &parameters,
    541  string &answer);
    542 
    557  const uint_fast16_t get_stream(const Mastodon::API::v1 &call,
    558  const parametermap &parameters,
    559  string &answer,
    560  std::unique_ptr<Mastodon::API::http> &ptr);
    561 
    575  const uint_fast16_t get_stream(const Mastodon::API::v1 &call,
    576  string &answer,
    577  std::unique_ptr<Mastodon::API::http> &ptr);
    578 
    593  const uint_fast16_t get_stream(const string &call,
    594  string &answer,
    595  std::unique_ptr<Mastodon::API::http> &ptr);
    596 
    597  [[deprecated("Will vanish in 1.0.0, use get_stream() without string "
    598  "argument instead.")]]
    599  const uint_fast16_t get_stream(const Mastodon::API::v1 &call,
    600  const string &argument,
    601  string &answer,
    602  std::unique_ptr<Mastodon::API::http> &ptr);
    603 
    619  const uint_fast16_t patch(const Mastodon::API::v1 &call,
    620  const parametermap &parameters,
    621  string &answer);
    622 
    635  const uint_fast16_t post(const Mastodon::API::v1 &call, string &answer);
    636 
    652  const uint_fast16_t post(const Mastodon::API::v1 &call,
    653  const parametermap &parameters,
    654  string &answer);
    655 
    671  const uint_fast16_t post(const string &call,
    672  const parametermap &parameters,
    673  string &answer);
    674 
    675  [[deprecated("Will vanish in 1.0.0, use post() without string argument "
    676  "instead.")]]
    677  const uint_fast16_t post(const Mastodon::API::v1 &call,
    678  const string &argument,
    679  string &answer);
    680 
    681  [[deprecated("Will vanish in 1.0.0, use post() without string argument "
    682  "instead.")]]
    683  const uint_fast16_t post(const Mastodon::API::v1 &call,
    684  const string &argument,
    685  const parametermap &parameters,
    686  string &answer);
    687 
    702  const uint_fast16_t put(const Mastodon::API::v1 &call,
    703  const parametermap &parameters,
    704  string &answer);
    705 
    720  const uint_fast16_t put(const string &call,
    721  const parametermap &parameters,
    722  string &answer);
    723 
    724  [[deprecated("Will vanish in 1.0.0, use put() without string argument "
    725  "instead.")]]
    726  const uint_fast16_t put(const Mastodon::API::v1 &call,
    727  const string &argument,
    728  const parametermap &parameters,
    729  string &answer);
    730 
    741  const uint_fast16_t del(const Mastodon::API::v1 &call,
    742  const parametermap &parameters);
    743 
    757  const uint_fast16_t del(const string &call,
    758  const parametermap &parameters,
    759  string &answer);
    760 
    761  [[deprecated("Will vanish in 1.0.0, use del() without string argument "
    762  "instead.")]]
    763  const uint_fast16_t del(const Mastodon::API::v1 &call,
    764  const string &argument);
    765 
    766  [[deprecated("Will vanish in 1.0.0, use del() without string argument "
    767  "instead.")]]
    768  const uint_fast16_t del(const Mastodon::API::v1 &call,
    769  const string &argument,
    770  const parametermap &parameters);
    771 
    772 private:
    773  const string _instance;
    774  string _access_token;
    775  string _useragent;
    776  http _http;
    777  bool _exceptions;
    778  string _proxy;
    779  string _proxy_userpw;
    780 
    789  const string maptostr(const parametermap &map,
    790  const bool &firstparam = true);
    791 
    799  const curlpp::Forms maptoformdata(const parametermap &map);
    800 };
    801 }
    802 
    803 #endif
    Class for the Mastodon API.
    Definition: mastodon-cpp.hpp:76
    +
    1 /* This file is part of mastodon-cpp.
    2  * Copyright © 2018 tastytea <tastytea@tastytea.de>
    3  *
    4  * This program is free software: you can redistribute it and/or modify
    5  * it under the terms of the GNU General Public License as published by
    6  * the Free Software Foundation, version 3.
    7  *
    8  * This program is distributed in the hope that it will be useful,
    9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    11  * GNU General Public License for more details.
    12  *
    13  * You should have received a copy of the GNU General Public License
    14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    15  */
    16 
    17 #ifndef MASTODON_CPP_HPP
    18 #define MASTODON_CPP_HPP
    19 
    20 #include <string>
    21 #include <vector>
    22 #include <cstdint>
    23 #include <map>
    24 #include <memory>
    25 #include <array>
    26 #include <mutex>
    27 #include <curlpp/cURLpp.hpp>
    28 #include <curlpp/Easy.hpp>
    29 
    30 using std::uint_fast16_t;
    31 using std::string;
    32 
    52 namespace Mastodon
    53 {
    77 class API
    78 {
    79 public:
    85  class http
    86  {
    87  public:
    91  enum class method
    92  {
    93  GET,
    94  PATCH,
    95  POST,
    96  PUT,
    97  DELETE,
    98  GET_STREAM
    99  };
    100 
    101  explicit http(const API &api, const string &instance,
    102  const string &access_token);
    103  ~http();
    104  const uint_fast16_t request(const method &meth,
    105  const string &path,
    106  string &answer);
    107 
    121  const uint_fast16_t request(const method &meth,
    122  const string &path,
    123  const curlpp::Forms &formdata,
    124  string &answer);
    125 
    129  const void get_headers(string &headers) const;
    130 
    141  const void cancel_stream();
    142 
    143  [[deprecated("Will vanish in 1.0.0. Use cancel_stream() instead.")]]
    144  const void abort_stream();
    145 
    156  std::mutex &get_mutex();
    157 
    158  private:
    159  const API &parent;
    160  const string _instance;
    161  const string _access_token;
    162  string _headers;
    163  bool _cancel_stream;
    164  std::mutex _mutex;
    165 
    166  const size_t callback_write(char* data, size_t size, size_t nmemb,
    167  string *oss);
    168  [[deprecated("Will vanish in 1.0.0. Use callback_write() instead.")]]
    169  const size_t callback(char* data, size_t size, size_t nmemb,
    170  string *oss);
    171  double callback_progress(double /* dltotal */, double /* dlnow */,
    172  double /* ultotal */, double /* ulnow */);
    173  };
    174 
    189  typedef std::map<string, std::vector<string>> parametermap;
    190 
    198  enum class v1
    199  {
    200  accounts_id,
    201  accounts_verify_credentials,
    202  accounts_id_followers,
    203  accounts_id_following,
    204  accounts_id_statuses,
    205  accounts_relationships,
    206  accounts_search,
    207  blocks,
    208  domain_blocks,
    209  favourites,
    210  follow_requests,
    211  instance,
    212  custom_emojis,
    213  lists,
    214  accounts_id_lists,
    215  lists_id_accounts,
    216  lists_id,
    217  mutes,
    218  notifications,
    219  notifications_id,
    220  reports,
    221  search,
    222  statuses_id,
    223  statuses_id_context,
    224  statuses_id_card,
    225  statuses_id_reblogged_by,
    226  statuses_id_favourited_by,
    227  timelines_home,
    228  timelines_public,
    229  timelines_tag_hashtag,
    230  timelines_list_list_id,
    231  // PATCH
    232  accounts_update_credentials,
    233  // POST
    234  accounts_id_follow,
    235  accounts_id_unfollow,
    236  accounts_id_block,
    237  accounts_id_unblock,
    238  accounts_id_mute,
    239  accounts_id_unmute,
    240  apps,
    241  follow_requests_id_authorize,
    242  follow_requests_id_reject,
    243  follows,
    244  media,
    245  notifications_clear,
    246  notifications_dismiss,
    247  statuses,
    248  statuses_id_reblog,
    249  statuses_id_unreblog,
    250  statuses_id_favourite,
    251  statuses_id_unfavourite,
    252  statuses_id_pin,
    253  statuses_id_unpin,
    254  statuses_id_mute,
    255  statuses_id_unmute,
    256  // PUT
    257  media_id,
    258  // Streaming
    259  streaming_user,
    260  streaming_public,
    261  streaming_public_local,
    262  streaming_hashtag,
    263  streaming_list,
    264  // Push
    265  push_subscription
    266  };
    267 
    275  enum class v2
    276  {
    277  search
    278  };
    279 
    291  explicit API(const string &instance, const string &access_token);
    292 
    300  const void set_useragent(const string &useragent);
    301 
    309  const string get_useragent() const;
    310 
    318  const string get_instance() const;
    319 
    337  static const string urlencode(const string &str);
    338 
    352  static const string urldecode(const string &str);
    353 
    371  const uint_fast16_t register_app1(const string &client_name,
    372  const string &redirect_uri,
    373  const string &scopes,
    374  const string &website,
    375  string &client_id,
    376  string &client_secret,
    377  string &url);
    378 
    379  [[deprecated("Will vanish in 1.0.0")]]
    380  const uint_fast16_t register_app1(const string &instance,
    381  const string &client_name,
    382  const string &redirect_uri,
    383  const string &scopes,
    384  const string &website,
    385  string &client_id,
    386  string &client_secret,
    387  string &url);
    388 
    404  const uint_fast16_t register_app2(const string &client_id,
    405  const string &client_secret,
    406  const string &redirect_uri,
    407  const string &code,
    408  string &access_token);
    409 
    410  [[deprecated("Will vanish in 1.0.0")]]
    411  const uint_fast16_t register_app2(const string &instance,
    412  const string &client_id,
    413  const string &client_secret,
    414  const string &redirect_uri,
    415  const string &code,
    416  string &access_token);
    417 
    427  const string get_header(const string &header) const;
    428 
    441  bool exceptions(const bool &value);
    442 
    446  const bool exceptions() const;
    447 
    455  static const string unescape_html(const string &html);
    456 
    468  const void set_proxy(const string &proxy, const string &userpw = "");
    469 
    478  const void get_proxy(string &proxy, string &userpw) const;
    479 
    491  const uint_fast16_t get(const Mastodon::API::v1 &call, string &answer);
    492 
    504  const uint_fast16_t get(const Mastodon::API::v1 &call,
    505  const parametermap &parameters,
    506  string &answer);
    507 
    513  const uint_fast16_t get(const Mastodon::API::v2 &call,
    514  const parametermap &parameters,
    515  string &answer);
    516 
    529  const uint_fast16_t get(const string &call, string &answer);
    530 
    531  [[deprecated("Will vanish in 1.0.0, use get() without string argument "
    532  "instead.")]]
    533  const uint_fast16_t get(const Mastodon::API::v1 &call,
    534  const string &argument,
    535  string &answer);
    536 
    537  [[deprecated("Will vanish in 1.0.0, use get() without string argument "
    538  "instead.")]]
    539  const uint_fast16_t get(const Mastodon::API::v1 &call,
    540  const string &argument,
    541  const parametermap &parameters,
    542  string &answer);
    543 
    558  const uint_fast16_t get_stream(const Mastodon::API::v1 &call,
    559  const parametermap &parameters,
    560  string &answer,
    561  std::unique_ptr<Mastodon::API::http> &ptr);
    562 
    576  const uint_fast16_t get_stream(const Mastodon::API::v1 &call,
    577  string &answer,
    578  std::unique_ptr<Mastodon::API::http> &ptr);
    579 
    594  const uint_fast16_t get_stream(const string &call,
    595  string &answer,
    596  std::unique_ptr<Mastodon::API::http> &ptr);
    597 
    598  [[deprecated("Will vanish in 1.0.0, use get_stream() without string "
    599  "argument instead.")]]
    600  const uint_fast16_t get_stream(const Mastodon::API::v1 &call,
    601  const string &argument,
    602  string &answer,
    603  std::unique_ptr<Mastodon::API::http> &ptr);
    604 
    620  const uint_fast16_t patch(const Mastodon::API::v1 &call,
    621  const parametermap &parameters,
    622  string &answer);
    623 
    636  const uint_fast16_t post(const Mastodon::API::v1 &call, string &answer);
    637 
    653  const uint_fast16_t post(const Mastodon::API::v1 &call,
    654  const parametermap &parameters,
    655  string &answer);
    656 
    672  const uint_fast16_t post(const string &call,
    673  const parametermap &parameters,
    674  string &answer);
    675 
    676  [[deprecated("Will vanish in 1.0.0, use post() without string argument "
    677  "instead.")]]
    678  const uint_fast16_t post(const Mastodon::API::v1 &call,
    679  const string &argument,
    680  string &answer);
    681 
    682  [[deprecated("Will vanish in 1.0.0, use post() without string argument "
    683  "instead.")]]
    684  const uint_fast16_t post(const Mastodon::API::v1 &call,
    685  const string &argument,
    686  const parametermap &parameters,
    687  string &answer);
    688 
    703  const uint_fast16_t put(const Mastodon::API::v1 &call,
    704  const parametermap &parameters,
    705  string &answer);
    706 
    721  const uint_fast16_t put(const string &call,
    722  const parametermap &parameters,
    723  string &answer);
    724 
    725  [[deprecated("Will vanish in 1.0.0, use put() without string argument "
    726  "instead.")]]
    727  const uint_fast16_t put(const Mastodon::API::v1 &call,
    728  const string &argument,
    729  const parametermap &parameters,
    730  string &answer);
    731 
    742  const uint_fast16_t del(const Mastodon::API::v1 &call,
    743  const parametermap &parameters);
    744 
    758  const uint_fast16_t del(const string &call,
    759  const parametermap &parameters,
    760  string &answer);
    761 
    762  [[deprecated("Will vanish in 1.0.0, use del() without string argument "
    763  "instead.")]]
    764  const uint_fast16_t del(const Mastodon::API::v1 &call,
    765  const string &argument);
    766 
    767  [[deprecated("Will vanish in 1.0.0, use del() without string argument "
    768  "instead.")]]
    769  const uint_fast16_t del(const Mastodon::API::v1 &call,
    770  const string &argument,
    771  const parametermap &parameters);
    772 
    773 private:
    774  const string _instance;
    775  string _access_token;
    776  string _useragent;
    777  http _http;
    778  bool _exceptions;
    779  string _proxy;
    780  string _proxy_userpw;
    781 
    790  const string maptostr(const parametermap &map,
    791  const bool &firstparam = true);
    792 
    800  const curlpp::Forms maptoformdata(const parametermap &map);
    801 };
    802 }
    803 
    804 #endif
    Class for the Mastodon API.
    Definition: mastodon-cpp.hpp:77
    const uint_fast16_t del(const Mastodon::API::v1 &call, const parametermap &parameters)
    Make a DELETE request which requires parameters.
    Definition: delete.cpp:23
    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
    static const string urldecode(const string &str)
    Decodes a percent-encoded string.
    Definition: mastodon-cpp.cpp:146
    -
    const void get_headers(string &headers) const
    Get all headers in a string.
    Definition: http.cpp:189
    -
    v1
    A list of all v1 API calls.
    Definition: mastodon-cpp.hpp:197
    -
    v2
    A list of all v2 API calls.
    Definition: mastodon-cpp.hpp:274
    +
    const void get_headers(string &headers) const
    Get all headers in a string.
    Definition: http.cpp:197
    +
    v1
    A list of all v1 API calls.
    Definition: mastodon-cpp.hpp:198
    +
    v2
    A list of all v2 API calls.
    Definition: mastodon-cpp.hpp:275
    const string get_header(const string &header) const
    Gets the header from the last answer.
    Definition: mastodon-cpp.cpp:262
    const 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
    const void get_proxy(string &proxy, string &userpw) const
    For internal use.
    Definition: mastodon-cpp.cpp:595
    @@ -61,20 +61,20 @@ $(function() {
    API(const string &instance, const string &access_token)
    Constructs a new API object.
    Definition: mastodon-cpp.cpp:30
    const void set_proxy(const string &proxy, const string &userpw="")
    Sets the proxy.
    Definition: mastodon-cpp.cpp:589
    const uint_fast16_t get_stream(const Mastodon::API::v1 &call, const parametermap &parameters, string &answer, std::unique_ptr< Mastodon::API::http > &ptr)
    Make a streaming GET request.
    Definition: get_stream.cpp:24
    -
    method
    HTTP methods.
    Definition: mastodon-cpp.hpp:90
    +
    method
    HTTP methods.
    Definition: mastodon-cpp.hpp:91
    const uint_fast16_t post(const Mastodon::API::v1 &call, string &answer)
    Make a POST request which doesn&#39;t require parameters.
    Definition: post.cpp:128
    const uint_fast16_t patch(const Mastodon::API::v1 &call, const parametermap &parameters, string &answer)
    Make a PATCH request.
    Definition: patch.cpp:24
    const 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
    const uint_fast16_t put(const Mastodon::API::v1 &call, const parametermap &parameters, string &answer)
    Make a PUT request which requires a parameters.
    Definition: put.cpp:23
    const bool exceptions() const
    Returns true if exceptions are turned on, false otherwise.
    Definition: mastodon-cpp.cpp:283
    Definition: mastodon-cpp.hpp:52
    -
    std::map< string, std::vector< string > > parametermap
    Used for passing parameters.
    Definition: mastodon-cpp.hpp:188
    +
    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:84
    +
    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
    -
    const void cancel_stream()
    Cancels the stream. Use only with streams.
    Definition: http.cpp:220
    -
    std::mutex & get_mutex()
    Gets the mutex guarding the string that is written to.
    Definition: http.cpp:230
    +
    const void cancel_stream()
    Cancels the stream. Use only with streams.
    Definition: http.cpp:228
    +
    std::mutex & get_mutex()
    Gets the mutex guarding the string that is written to.
    Definition: http.cpp:238