Ported to mastodon-cpp 0.105.0.

This commit is contained in:
tastytea 2019-04-21 04:35:21 +02:00
parent dbf5741fbf
commit adead24ba2
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 11 additions and 12 deletions

View File

@ -28,7 +28,8 @@
#include "version.hpp" #include "version.hpp"
namespace pt = boost::property_tree; namespace pt = boost::property_tree;
using Mastodon::API; using namespace Mastodon;
using std::cout; using std::cout;
using std::string; using std::string;
@ -95,7 +96,7 @@ string get_ingredient(std::vector<string> &vector)
return ingredient; return ingredient;
} }
int main(int argc, char *argv[]) int main()
{ {
pt::ptree config; pt::ptree config;
string instance = ""; string instance = "";
@ -167,27 +168,25 @@ int main(int argc, char *argv[])
toot += ", \nand plenty oil. Salt to taste. \n\nHappy cooking! 🍲 \n\n#bot"; toot += ", \nand plenty oil. Salt to taste. \n\nHappy cooking! 🍲 \n\n#bot";
return_call ret;
string answer; API masto(instance, access_token);
std::uint16_t ret;
Mastodon::API masto(instance, access_token);
masto.set_useragent("soupbot/" + (string)global::version); masto.set_useragent("soupbot/" + (string)global::version);
API::parametermap parameters = parameters params =
{ {
{ "status", { toot } }, { "status", { toot } },
{ "visibility", { "public" } } { "visibility", { "public" } }
}; };
ret = masto.post(API::v1::statuses, parameters, answer); ret = masto.post(API::v1::statuses, params);
if (ret == 0) if (ret)
{ {
cout << answer << '\n'; cout << ret.answer << '\n';
} }
else else
{ {
std::cerr << "Error code: " << ret << '\n'; std::cerr << "Error code: " << ret.error_code << '\n';
return ret; return ret.error_code;
} }
return 0; return 0;