• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

tastytea/mastodonpp: [mirror] C++ wrapper for the Mastodon and Pleroma APIs.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

tastytea/mastodonpp

开源软件地址(OpenSource Url):

https://github.com/tastytea/mastodonpp

开源编程语言(OpenSource Language):

C++ 90.8%

开源软件介绍(OpenSource Introduction):

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 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!

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/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

Packaging status

Gentoo

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

Arch

The git-version is available via the AUR: https://aur.archlinux.org/packages/mastodonpp-git/.

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.

  • -DWITH_DOC=YES if you want to generate the API documentation.

  • -DWITH_CLANG-TIDY=YES to check the sourcecode with clang-tidy while compiling.

  • 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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap