From f37557cd646fbf2e96c08e5ca4cea59f757a288d Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 19 Apr 2018 00:36:39 +0200 Subject: [PATCH] updated examples --- examples/example01_dump_json.cpp | 3 ++- examples/example03_mastocron.cpp | 3 ++- examples/example05_follow_unfollow.cpp | 6 +++--- examples/example06_toot_delete-toot.cpp | 2 +- examples/example09_streaming_api.cpp | 3 ++- examples/example12_easy_laststatus.cpp | 6 ++++-- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/examples/example01_dump_json.cpp b/examples/example01_dump_json.cpp index 7d29e3a..b47a1f5 100644 --- a/examples/example01_dump_json.cpp +++ b/examples/example01_dump_json.cpp @@ -35,11 +35,12 @@ int main(int argc, char *argv[]) std::string uid = answer.substr(7, answer.find("\"", 7) - 7); API::parametermap parameters = { + { "id", { uid } }, { "limit", { "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) { std::cout << answer << '\n'; diff --git a/examples/example03_mastocron.cpp b/examples/example03_mastocron.cpp index 613114f..cf14c9a 100644 --- a/examples/example03_mastocron.cpp +++ b/examples/example03_mastocron.cpp @@ -58,10 +58,11 @@ int main(int argc, char *argv[]) // Only get toots we haven't seen yet API::parametermap params = { + { "hashtag", { hashtag } }, { "limit", { limit } }, { "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) { diff --git a/examples/example05_follow_unfollow.cpp b/examples/example05_follow_unfollow.cpp index b2d2b95..6a4e887 100644 --- a/examples/example05_follow_unfollow.cpp +++ b/examples/example05_follow_unfollow.cpp @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) // If no @ is found, it is presumably an ID 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) { // std::cout << answer << '\n'; @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) std::cout << "Unfollowing in 30 seconds...\n"; 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) { // std::cout << answer << '\n'; @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) std::cout << "Unfollowing " << id << " in 30 seconds...\n"; 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) { // std::cout << answer << '\n'; diff --git a/examples/example06_toot_delete-toot.cpp b/examples/example06_toot_delete-toot.cpp index 6361b49..2f90189 100644 --- a/examples/example06_toot_delete-toot.cpp +++ b/examples/example06_toot_delete-toot.cpp @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) std::cout << "Deleting in 30 seconds...\n"; 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) { std::cout << "Status " << id << " deleted.\n"; diff --git a/examples/example09_streaming_api.cpp b/examples/example09_streaming_api.cpp index 13de09e..dbce559 100644 --- a/examples/example09_streaming_api.cpp +++ b/examples/example09_streaming_api.cpp @@ -59,7 +59,8 @@ int main(int argc, char *argv[]) { Mastodon::API masto(argv[1], argv[2]); 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)); ptr->abort_stream(); diff --git a/examples/example12_easy_laststatus.cpp b/examples/example12_easy_laststatus.cpp index f17d2b7..737daf0 100644 --- a/examples/example12_easy_laststatus.cpp +++ b/examples/example12_easy_laststatus.cpp @@ -44,8 +44,10 @@ int main(int argc, char *argv[]) // Get last status ret = masto.get(API::v1::accounts_id_statuses, - std::to_string(acc.id()), - {{ "limit", { "1" } }}, + { + { "id", { std::to_string(acc.id()) } }, + { "limit", { "1" } } + }, answer); if (ret == 0) {