Browse Source

updated examples

tastytea 9 months 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[])
35 35
         std::string uid = answer.substr(7, answer.find("\"", 7) - 7);
36 36
         API::parametermap parameters =
37 37
         {
38
+            { "id", { uid } },
38 39
             { "limit", { "1" } },
39 40
             { "only_media", { "1" } }
40 41
         };
41 42
 
42
-        ret = masto.get(API::v1::accounts_id_statuses, uid,parameters, answer);
43
+        ret = masto.get(API::v1::accounts_id_statuses, parameters, answer);
43 44
         if (ret == 0)
44 45
         {
45 46
             std::cout << answer << '\n';

+ 2
- 1
examples/example03_mastocron.cpp View File

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

+ 3
- 3
examples/example05_follow_unfollow.cpp View File

@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
36 36
     // If no @ is found, it is presumably an ID
37 37
     if (id.find('@') == std::string::npos)
38 38
     {
39
-        ret = masto.post(API::v1::accounts_id_follow, id, answer);
39
+        ret = masto.post(API::v1::accounts_id_follow, {{"id", {id}}}, answer);
40 40
         if (ret == 0)
41 41
         {
42 42
             // std::cout << answer << '\n';
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
55 55
 
56 56
         std::cout << "Unfollowing in 30 seconds...\n";
57 57
         std::this_thread::sleep_for(std::chrono::seconds(30));
58
-        ret = masto.post(API::v1::accounts_id_unfollow, id, answer);
58
+        ret = masto.post(API::v1::accounts_id_unfollow, {{"id", {id}}}, answer);
59 59
         if (ret == 0)
60 60
         {
61 61
             // std::cout << answer << '\n';
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
86 86
 
87 87
         std::cout << "Unfollowing " << id << " in 30 seconds...\n";
88 88
         std::this_thread::sleep_for(std::chrono::seconds(30));
89
-        ret = masto.post(API::v1::accounts_id_unfollow, id, answer);
89
+        ret = masto.post(API::v1::accounts_id_unfollow, {{"id", {id}}}, answer);
90 90
         if (ret == 0)
91 91
         {
92 92
             // std::cout << answer << '\n';

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

@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
47 47
 
48 48
         std::cout << "Deleting in 30 seconds...\n";
49 49
         std::this_thread::sleep_for(std::chrono::seconds(30));
50
-        ret = masto.del(API::v1::statuses_id, id);
50
+        ret = masto.del(API::v1::statuses_id, {{"id", {id}}});
51 51
         if (ret == 0)
52 52
         {
53 53
             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[])
59 59
     {
60 60
         Mastodon::API masto(argv[1], argv[2]);
61 61
         masto.set_useragent("mastodon-cpp-example/1.3.3.7");
62
-        masto.get_stream(API::v1::streaming_hashtag, "np", answer, ptr);
62
+        masto.get_stream(API::v1::streaming_hashtag, {{ "hashtag", {"np"} }},
63
+                         answer, ptr);
63 64
     });
64 65
     std::this_thread::sleep_for(std::chrono::seconds(20));
65 66
     ptr->abort_stream();

+ 4
- 2
examples/example12_easy_laststatus.cpp View File

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

Loading…
Cancel
Save