Browse Source

updated examples

tags/0.10.0
tastytea 1 year ago
parent
commit
f37557cd64
Signed by: tastytea <tastytea@tastytea.de> GPG Key ID: 59346E0EA35C67E5

+ 2
- 1
examples/example01_dump_json.cpp View File

@@ -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';

+ 2
- 1
examples/example03_mastocron.cpp View File

@@ -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)
{

+ 3
- 3
examples/example05_follow_unfollow.cpp View File

@@ -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';

+ 1
- 1
examples/example06_toot_delete-toot.cpp View File

@@ -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";

+ 2
- 1
examples/example09_streaming_api.cpp View File

@@ -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();

+ 4
- 2
examples/example12_easy_laststatus.cpp View File

@@ -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)
{

Loading…
Cancel
Save