C++ wrapper for the Mastodon and Pleroma APIs.
Go to file
tastytea e40848fb1e
All checks were successful
continuous-integration/drone/push Build is passing
typo.
2020-01-18 23:32:51 +01:00
cmake Revert "Add -fsanitize=address to debug flags." 2020-01-16 18:05:22 +01:00
examples Change website in example08 to example.com. 2020-01-14 23:22:50 +01:00
include Indentation fix. 2020-01-18 18:09:49 +01:00
pkg-config Fix pkg-config file. 2020-01-10 20:20:05 +01:00
src Remove useless else. 2020-01-16 18:20:37 +01:00
tests Add test for unescape_html(). 2020-01-16 18:16:02 +01:00
.drone.yml Fix CI recipe. 2020-01-10 20:04:09 +01:00
.editorconfig
.gitignore
build_doc.sh
CMakeLists.txt Version bump 0.4.0. 2020-01-16 18:25:32 +01:00
CODE_OF_CONDUCT.adoc
CONTRIBUTING.adoc
Doxyfile
LICENSE
README.adoc typo. 2020-01-18 23:32:51 +01:00

mastodonpp

mastodonpp is a C++ wrapper for the Mastodon and Pleroma APIs. It replaces mastodon-cpp.

We aim to create a library that is comfortable, yet minimal. All API endpoints from Mastodon and Pleroma are stored in enum classes, to counteract typos and make your life easier. The network-facing code is built on libcurl, a mature and stable library that is available on virtually every operating system. The library does not parse the responses itself, but returns to you the raw data, because we know everyone has their favorite JSON library and we dont want to impose our choice on you!

Features

Here is a rough overview of the features:

  • GET, Streaming GET, POST, PATCH, PUT and DELETE requests.

  • ✓ Comfortable access to pagination headers.

  • ✓ Report maximum allowed character per post.

  • ✓ Simple function to register a new “app” (get an access token).

  • ✓ Report which mime types are allowed for posting statuses.

  • ✓ Find and retrieve NodeInfo.

  • ✓ Easy access to the libcurl handle for maximum configurability.

  • ✓ Set proxy server, User-Agent and the path to the CA bundle.

Usage

Have a look at the reference.

Example

#include "mastodonpp.hpp"
#include <iostream>

int main()
{
    mastodonpp::Instance instance{"example.com", "123AccessToken123"};
    instance.set_proxy("socks4a://[::1]:9050");
    mastodonpp::Connection connection{instance};

    const mastodonpp::parametermap parameters
        {
            {"status", "How is the weather?"},
            {"poll[options]", vector<string_view>{"Nice", "not nice"}},
            {"poll[expires_in]", "86400"}
        };
    auto answer{connection.post(mastodonpp::API::v1::statuses, parameters)};

    if (answer)
    {
        std::cout << answer << std::endl;
    }
}

More examples are included in the reference.

Install

Gentoo

eselect repository enable tastytea
echo 'dev-cpp/mastodonpp' >> /etc/portage/package.accept_keywords/mastodonpp
emaint sync -r tastytea
emerge -a dev-cpp/mastodonpp

Debian and Ubuntu

We automatically generate packages for Debian buster (10) and Ubuntu bionic (18.04), but only for x86_64 (amd64). Download them at schlomp.space.

apt install ./libmastodonpp*.deb

CentOS

We automatically generate packages for CentOS 8, but only for x86_64 (amd64). Download them at schlomp.space.

yum install ./libmastodonpp*.rpm

From source

Dependencies

  • Tested OS: Linux

  • C++ compiler with C++17 support (tested: GCC 7/8/9, clang 6/7)

  • CMake (at least: 3.9)

  • libcurl (at least: 7.56)

  • Optional

    • Documentation: Doxygen (tested: 1.8)

    • Tests: Catch (tested: 2.5 / 1.2)

    • DEB package: dpkg (tested: 1.19)

    • RPM package: rpm-build (tested: 4.11)

Get sourcecode

Release

Download the current release at schlomp.space.

Development version
git clone https://schlomp.space/tastytea/mastodonpp.git

Compile

mkdir -p build && cd build
cmake ..
cmake --build . -- -j$(nproc --ignore=1)
CMake options:
  • -DCMAKE_BUILD_TYPE=Debug for a debug build.

  • -DWITH_TESTS=YES if you want to compile the tests.

  • -DWITH_EXAMPLES=YES if you want to compile the examples.

  • One of:

    • -DWITH_DEB=YES if you want to be able to generate a deb-package.

    • -DWITH_RPM=YES if you want to be able to generate an rpm-package.

To create a deb or rpm package, run make package after compiling.