updated examples

This commit is contained in:
tastytea 2018-04-19 00:36:39 +02:00
parent 90452a9ec9
commit f37557cd64
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
6 changed files with 14 additions and 9 deletions

View File

@ -35,11 +35,12 @@ int main(int argc, char *argv[])
std::string uid = answer.substr(7, answer.find("\"", 7) - 7); std::string uid = answer.substr(7, answer.find("\"", 7) - 7);
API::parametermap parameters = API::parametermap parameters =
{ {
{ "id", { uid } },
{ "limit", { "1" } }, { "limit", { "1" } },
{ "only_media", { "1" } } { "only_media", { "1" } }
}; };
ret = masto.get(API::v1::accounts_id_statuses, uid,parameters, answer); ret = masto.get(API::v1::accounts_id_statuses, parameters, answer);
if (ret == 0) if (ret == 0)
{ {
std::cout << answer << '\n'; std::cout << answer << '\n';

View File

@ -58,10 +58,11 @@ int main(int argc, char *argv[])
// Only get toots we haven't seen yet // Only get toots we haven't seen yet
API::parametermap params = API::parametermap params =
{ {
{ "hashtag", { hashtag } },
{ "limit", { limit } }, { "limit", { limit } },
{ "since_id", { lastid } } { "since_id", { lastid } }
}; };
ret = masto.get(API::v1::timelines_tag_hashtag, hashtag, params, answer); ret = masto.get(API::v1::timelines_tag_hashtag, params, answer);
if (ret == 0) if (ret == 0)
{ {

View File

@ -36,7 +36,7 @@ int main(int argc, char *argv[])
// If no @ is found, it is presumably an ID // If no @ is found, it is presumably an ID
if (id.find('@') == std::string::npos) if (id.find('@') == std::string::npos)
{ {
ret = masto.post(API::v1::accounts_id_follow, id, answer); ret = masto.post(API::v1::accounts_id_follow, {{"id", {id}}}, answer);
if (ret == 0) if (ret == 0)
{ {
// std::cout << answer << '\n'; // std::cout << answer << '\n';
@ -55,7 +55,7 @@ int main(int argc, char *argv[])
std::cout << "Unfollowing in 30 seconds...\n"; std::cout << "Unfollowing in 30 seconds...\n";
std::this_thread::sleep_for(std::chrono::seconds(30)); std::this_thread::sleep_for(std::chrono::seconds(30));
ret = masto.post(API::v1::accounts_id_unfollow, id, answer); ret = masto.post(API::v1::accounts_id_unfollow, {{"id", {id}}}, answer);
if (ret == 0) if (ret == 0)
{ {
// std::cout << answer << '\n'; // std::cout << answer << '\n';
@ -86,7 +86,7 @@ int main(int argc, char *argv[])
std::cout << "Unfollowing " << id << " in 30 seconds...\n"; std::cout << "Unfollowing " << id << " in 30 seconds...\n";
std::this_thread::sleep_for(std::chrono::seconds(30)); std::this_thread::sleep_for(std::chrono::seconds(30));
ret = masto.post(API::v1::accounts_id_unfollow, id, answer); ret = masto.post(API::v1::accounts_id_unfollow, {{"id", {id}}}, answer);
if (ret == 0) if (ret == 0)
{ {
// std::cout << answer << '\n'; // std::cout << answer << '\n';

View File

@ -47,7 +47,7 @@ int main(int argc, char *argv[])
std::cout << "Deleting in 30 seconds...\n"; std::cout << "Deleting in 30 seconds...\n";
std::this_thread::sleep_for(std::chrono::seconds(30)); std::this_thread::sleep_for(std::chrono::seconds(30));
ret = masto.del(API::v1::statuses_id, id); ret = masto.del(API::v1::statuses_id, {{"id", {id}}});
if (ret == 0) if (ret == 0)
{ {
std::cout << "Status " << id << " deleted.\n"; std::cout << "Status " << id << " deleted.\n";

View File

@ -59,7 +59,8 @@ int main(int argc, char *argv[])
{ {
Mastodon::API masto(argv[1], argv[2]); Mastodon::API masto(argv[1], argv[2]);
masto.set_useragent("mastodon-cpp-example/1.3.3.7"); masto.set_useragent("mastodon-cpp-example/1.3.3.7");
masto.get_stream(API::v1::streaming_hashtag, "np", answer, ptr); masto.get_stream(API::v1::streaming_hashtag, {{ "hashtag", {"np"} }},
answer, ptr);
}); });
std::this_thread::sleep_for(std::chrono::seconds(20)); std::this_thread::sleep_for(std::chrono::seconds(20));
ptr->abort_stream(); ptr->abort_stream();

View File

@ -44,8 +44,10 @@ int main(int argc, char *argv[])
// Get last status // Get last status
ret = masto.get(API::v1::accounts_id_statuses, ret = masto.get(API::v1::accounts_id_statuses,
std::to_string(acc.id()), {
{{ "limit", { "1" } }}, { "id", { std::to_string(acc.id()) } },
{ "limit", { "1" } }
},
answer); answer);
if (ret == 0) if (ret == 0)
{ {