2020-01-03 06:08:47 +01:00
|
|
|
= mastodonpp
|
|
|
|
:toc: preamble
|
|
|
|
:project: mastodonpp
|
|
|
|
:uri-base: https://schlomp.space/tastytea/{project}
|
|
|
|
:uri-branch-main: {uri-base}/src/branch/main
|
2020-01-25 20:22:33 +01:00
|
|
|
:uri-wp-mastodon: https://en.wikipedia.org/wiki/Mastodon_(software)
|
|
|
|
:uri-pleroma: https://pleroma.social/
|
2020-01-03 06:08:47 +01:00
|
|
|
:uri-mastodon-cpp: https://schlomp.space/tastytea/mastodon-cpp
|
2020-01-03 13:29:46 +01:00
|
|
|
:uri-reference: https://doc.schlomp.space/{project}/
|
|
|
|
:uri-gcc: https://gcc.gnu.org/
|
2020-01-16 23:49:28 +01:00
|
|
|
:uri-clang: https://clang.llvm.org/
|
2020-01-03 13:29:46 +01:00
|
|
|
:uri-cmake: https://cmake.org/
|
|
|
|
:uri-doxygen: http://www.doxygen.nl/
|
|
|
|
:uri-catch: https://github.com/catchorg/Catch2
|
|
|
|
:uri-dpkg: https://packages.qa.debian.org/dpkg
|
|
|
|
:uri-rpm-build: http://www.rpm.org
|
2020-01-08 22:47:40 +01:00
|
|
|
:uri-libcurl: https://curl.haxx.se/libcurl/
|
2020-01-18 23:32:51 +01:00
|
|
|
:uri-nodeinfo: https://nodeinfo.diaspora.software/
|
2020-01-03 06:08:47 +01:00
|
|
|
|
2020-01-25 20:22:33 +01:00
|
|
|
*{project}* is a C++ wrapper for the link:{uri-wp-mastodon}[Mastodon] and
|
|
|
|
link:{uri-pleroma}[Pleroma] APIs. It replaces
|
2020-01-08 22:29:31 +01:00
|
|
|
link:{uri-mastodon-cpp}[mastodon-cpp].
|
|
|
|
|
|
|
|
We aim to create a library that is comfortable, yet minimal. All API endpoints
|
2020-01-19 20:52:55 +01:00
|
|
|
from Mastodon and Pleroma are stored in ``enum class``es, to counteract typos
|
|
|
|
and make your life easier. The network-facing code is built on
|
2020-01-08 22:47:40 +01:00
|
|
|
link:{uri-libcurl}[libcurl], a mature and stable library that is available on
|
2020-01-25 20:23:52 +01:00
|
|
|
most operating systems. 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 don't want to impose our choice on you!
|
2020-01-08 22:29:31 +01:00
|
|
|
|
|
|
|
== Features
|
|
|
|
|
2020-01-18 18:09:58 +01:00
|
|
|
Here is a rough overview of the features:
|
2020-01-08 22:29:31 +01:00
|
|
|
|
2020-01-18 18:09:58 +01:00
|
|
|
* [x] `GET`, Streaming `GET`, `POST`, `PATCH`, `PUT` and `DELETE` requests.
|
2020-01-14 20:44:58 +01:00
|
|
|
* [x] Comfortable access to pagination headers.
|
2020-01-18 18:09:58 +01:00
|
|
|
* [x] Report maximum allowed character per post.
|
|
|
|
* [x] Simple function to register a new “app” (get an access token).
|
2020-01-14 20:44:58 +01:00
|
|
|
* [x] Report which mime types are allowed for posting statuses.
|
2020-01-18 18:09:58 +01:00
|
|
|
* [x] Find and retrieve link:{uri-nodeinfo}[NodeInfo].
|
|
|
|
* [x] Easy access to the libcurl handle for maximum configurability.
|
|
|
|
* [x] Set proxy server, User-Agent and the path to the CA bundle.
|
2020-01-03 06:29:54 +01:00
|
|
|
|
2020-01-03 13:29:46 +01:00
|
|
|
== Usage
|
|
|
|
|
|
|
|
Have a look at the link:{uri-reference}[reference].
|
|
|
|
|
2020-01-08 22:29:31 +01:00
|
|
|
=== Example
|
|
|
|
|
|
|
|
[source,cpp]
|
|
|
|
--------------------------------------------------------------------------------
|
2020-01-18 23:37:57 +01:00
|
|
|
#include <mastodonpp/mastodonpp.hpp>
|
2020-01-08 22:29:31 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2020-01-10 21:11:03 +01:00
|
|
|
mastodonpp::Instance instance{"example.com", "123AccessToken123"};
|
2020-01-14 23:13:09 +01:00
|
|
|
instance.set_proxy("socks4a://[::1]:9050");
|
2020-01-08 22:29:31 +01:00
|
|
|
mastodonpp::Connection connection{instance};
|
2020-01-10 19:34:50 +01:00
|
|
|
|
|
|
|
const mastodonpp::parametermap parameters
|
|
|
|
{
|
2020-01-11 14:13:55 +01:00
|
|
|
{"status", "How is the weather?"},
|
2020-01-10 19:34:50 +01:00
|
|
|
{"poll[options]", vector<string_view>{"Nice", "not nice"}},
|
|
|
|
{"poll[expires_in]", "86400"}
|
|
|
|
};
|
|
|
|
auto answer{connection.post(mastodonpp::API::v1::statuses, parameters)};
|
|
|
|
|
2020-01-08 22:29:31 +01:00
|
|
|
if (answer)
|
|
|
|
{
|
|
|
|
std::cout << answer << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
link:{uri-reference}/examples.html[More examples] are included in the reference.
|
2020-01-03 13:29:46 +01:00
|
|
|
|
|
|
|
== Install
|
|
|
|
|
2020-01-10 19:42:46 +01:00
|
|
|
=== Gentoo
|
|
|
|
|
|
|
|
[source,shell]
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
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
|
2020-01-10 21:14:18 +01:00
|
|
|
(18.04), but only for x86_64 (amd64). Download them at
|
2020-01-10 19:42:46 +01:00
|
|
|
link:{uri-base}/releases[schlomp.space].
|
|
|
|
|
|
|
|
[source,shell]
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
apt install ./libmastodonpp*.deb
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=== CentOS
|
|
|
|
|
|
|
|
We automatically generate packages for CentOS 8, but only for x86_64
|
2020-01-10 21:14:18 +01:00
|
|
|
(amd64). Download them at link:{uri-base}/releases[schlomp.space].
|
2020-01-10 19:42:46 +01:00
|
|
|
|
|
|
|
[source,shell]
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
yum install ./libmastodonpp*.rpm
|
|
|
|
--------------------------------------------------------------------------------
|
2020-01-03 13:29:46 +01:00
|
|
|
|
|
|
|
=== From source
|
|
|
|
|
|
|
|
==== Dependencies
|
|
|
|
|
|
|
|
* Tested OS: Linux
|
2020-01-17 17:29:44 +01:00
|
|
|
* C\++ compiler with C++17 support (tested: link:{uri-gcc}[GCC] 7/8/9,
|
|
|
|
link:{uri-clang}[clang] 6/7)
|
2020-01-03 13:29:46 +01:00
|
|
|
* link:{uri-cmake}[CMake] (at least: 3.9)
|
2020-01-10 14:27:15 +01:00
|
|
|
* link:{uri-libcurl}[libcurl] (at least: 7.56)
|
2020-01-03 13:29:46 +01:00
|
|
|
* Optional
|
|
|
|
** Documentation: link:{uri-doxygen}[Doxygen] (tested: 1.8)
|
|
|
|
** Tests: link:{uri-catch}[Catch] (tested: 2.5 / 1.2)
|
2020-01-14 23:49:15 +01:00
|
|
|
** DEB package: link:{uri-dpkg}[dpkg] (tested: 1.19)
|
2020-01-09 16:18:47 +01:00
|
|
|
** RPM package: link:{uri-rpm-build}[rpm-build] (tested: 4.11)
|
2020-01-03 13:29:46 +01:00
|
|
|
|
|
|
|
==== Get sourcecode
|
|
|
|
|
|
|
|
===== Release
|
|
|
|
|
|
|
|
Download the current release at link:{uri-base}/releases[schlomp.space].
|
|
|
|
|
|
|
|
===== Development version
|
|
|
|
|
|
|
|
[source,shell]
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
git clone https://schlomp.space/tastytea/mastodonpp.git
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
==== Compile
|
|
|
|
|
|
|
|
[source,shell]
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
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.
|
2020-01-09 19:25:27 +01:00
|
|
|
* 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.
|
2020-01-03 13:29:46 +01:00
|
|
|
|
2020-01-18 23:24:15 +01:00
|
|
|
To create a deb or rpm package, run `make package` after compiling.
|
|
|
|
|
2020-01-03 06:29:54 +01:00
|
|
|
include::{uri-base}/raw/branch/main/CONTRIBUTING.adoc[]
|