2018-03-07 17:17:26 +01:00
**mastodon-cpp** is a C++ wrapper for the Mastodon API.
2018-01-09 22:12:11 +01:00
The library takes care of the network stuff. You submit a query and get the raw JSON.
2018-01-06 21:33:52 +01:00
2018-03-18 14:02:53 +01:00
[TODO-list ](https://github.com/tastytea/mastodon-cpp/milestones )
2018-03-18 01:43:09 +01:00
# Usage
The HTML reference can be generated with `build_doc.sh` , if doxygen is installed.
Or just look in `src/mastodon-cpp.hpp` . It is also available at [tastytea.github.io/mastodon-cpp/ ](https://tastytea.github.io/mastodon-cpp/docs/classMastodon_1_1API.html ).
There are [examples ](https://github.com/tastytea/mastodon-cpp/tree/master/src/examples ) in `src/examples/` .
2018-03-21 17:08:33 +01:00
## Upgrading from below 0.7.0
The header location has changed. It is now in `mastodon-cpp/` .
2018-03-18 01:43:09 +01:00
## Most basic example
```C++
#include <iostream>
#include <string>
2018-03-21 17:08:33 +01:00
#include <mastodon-cpp/mastodon-cpp.hpp>
2018-03-18 01:43:09 +01:00
int main()
{
Mastodon::API masto("social.example.com", "auth_token");
std::string answer;
masto.get(Mastodon::API::v1::accounts_verify_credentials, answer);
std::cout < < answer << ' \n';
}
```
## Compiling your project
After you did a `make install` , a project consisting of one file can be compiled as follows:
g++ -std=c++14 -lmastodon-cpp example.cpp
## Error codes
mastodon-cpp will never use error codes below 11, except 0.
| Code | Explanation |
| --------: |:------------------------------|
| 0 | No error |
| 11 | Invalid call |
| 12 | Not implemented |
| 13 | URL changed (HTTP 301 or 308) |
| 14 | Aborted by user |
| 20 | Failed to connect |
| 21 | Couldn't resolve host |
| 22 | Network is unreachable |
| 100 - 999 | HTTP status codes |
| 65535 | Unknown error |
If you use a debug build, you get more verbose error messages.
## Useful links
* [Mastodon API reference ](https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md )
* [Mastodon streaming API reference ](https://github.com/tootsuite/documentation/blob/master/Using-the-API/Streaming-API.md )
2018-01-06 21:33:52 +01:00
# Install
2018-01-13 15:49:46 +01:00
2018-03-18 01:32:54 +01:00
## Packages
Every [release ](https://github.com/tastytea/mastodon-cpp/releases ) includes
packages for the package managers of Gentoo, Debian and Red Hat.
### Gentoo
2018-03-18 01:43:09 +01:00
Put the ebuild into your [local overlay ](https://wiki.gentoo.org/wiki/Custom_repository ) and run `ebuild \<ebuild path\> manifest` .
2018-03-18 01:32:54 +01:00
Install with `emerge mastodon-cpp` .
### DEB and RPM
Prebuilt DEB and RPM packages for x86_64(amd64) are provided with each release.
These packages are automatically built and not tested.
Install with `dpkg -i` or `rpm -i` , respectively.
To use the DEB package on stretch, you will need [libcurlpp0 ](https://packages.debian.org/de/libcurlpp0 ) from buster or jessie.
## From source
### Dependencies
2018-01-13 15:49:46 +01:00
2018-03-08 11:07:41 +01:00
* Tested OS: GNU/Linux
2018-03-12 10:14:24 +01:00
* C++ compiler (tested: gcc 6.4/5.4, clang 5.0)
2018-03-08 11:07:41 +01:00
* [cmake ](https://cmake.org/ ) (tested: 3.9.6)
2018-03-12 10:14:24 +01:00
* [libcurl ](https://curl.haxx.se/ ) (tested: 7.58.0/7.35.0)
* [curlpp ](http://www.curlpp.org/ ) (tested: 0.8.1/0.7.3)
2018-03-08 11:07:41 +01:00
* Optional
2018-03-21 17:08:33 +01:00
* Easy interface & Examples: [jsoncpp ](https://github.com/open-source-parsers/jsoncpp ) (tested: 1.8.1 / 1.7.2)
2018-03-08 11:07:41 +01:00
* Documentation: [doxygen ](https://www.stack.nl/~dimitri/doxygen/ ) (tested: 1.8.13)
* DEB package: [dpkg ](https://packages.qa.debian.org/dpkg ) (tested: 1.19.0.5)
2018-03-12 11:48:41 +01:00
* RPM package: [rpm ](http://www.rpm.org ) (tested: 4.11.0.1)
2018-01-06 21:33:52 +01:00
2018-03-18 01:32:54 +01:00
### Get sourcecode
2018-01-13 15:49:46 +01:00
2018-03-18 01:32:54 +01:00
#### Release
2018-01-13 21:12:07 +01:00
Download the current release at [GitHub ](https://github.com/tastytea/mastodon-cpp/releases ).
2018-03-18 01:32:54 +01:00
#### Development version
2018-01-13 15:49:46 +01:00
2018-03-12 09:18:49 +01:00
[![Build Status ](https://travis-ci.org/tastytea/mastodon-cpp.svg?branch=master )](https://travis-ci.org/tastytea/mastodon-cpp)
2018-01-13 16:07:00 +01:00
git clone https://github.com/tastytea/mastodon-cpp.git
2018-01-06 21:33:52 +01:00
2018-03-18 01:32:54 +01:00
### Compile
2018-01-13 15:49:46 +01:00
2018-01-06 21:33:52 +01:00
mkdir build
cd build/
cmake ..
make
2018-01-13 21:12:07 +01:00
cmake options:
* `-DCMAKE_BUILD_TYPE=Debug` for a debug build
2018-03-21 17:08:33 +01:00
* `-DWITHOUT_EASY=ON` to not build the Easy abstractions and to get rid of the jsoncpp-dependency (not recommended)
2018-01-13 21:12:07 +01:00
* `-DWITH_EXAMPLES=ON` if you want to compile the examples
* `-DWITH_TESTS=ON` if you want to compile the tests
* `-DWITH_DOC=ON` if you want to compile the HTML reference
2018-03-08 11:07:41 +01:00
* `-DWITH_DEB=ON` if you want to be able to generate a deb-package
* `-DWITH_RPM=ON` if you want to be able to generate an rpm-package
2018-01-13 21:12:07 +01:00
You can run the tests with `ctest ..` inside the build directory.
2018-03-18 01:32:54 +01:00
To install, run `make install`
2018-03-08 11:07:41 +01:00
2018-03-18 01:32:54 +01:00
### Packages
2018-03-08 11:07:41 +01:00
2018-03-18 01:32:54 +01:00
#### Gentoo
2018-03-08 11:07:41 +01:00
2018-03-18 01:43:09 +01:00
Put the ebuild in `packages/gentoo` into your [local overlay ](https://wiki.gentoo.org/wiki/Custom_repository ) and rename it to match the desired version or use the live-ebuild (`mastodon-cpp-9999.ebuild`) to install the development version.
2018-03-12 10:38:52 +01:00
2018-03-18 01:32:54 +01:00
#### DEB and RPM
2018-03-08 11:07:41 +01:00
Compile with `-DWITH_DEB=ON` or `-DWITH_RPM=ON` .
Run `make package` from the build directory to generate a DEB/RPM package.
2018-03-18 01:32:54 +01:00
#### Other
2018-03-08 11:07:41 +01:00
2018-03-18 01:32:54 +01:00
Run `make package` from the build directory to generate a tar.gz archive.
2018-01-13 15:49:46 +01:00
2018-03-08 11:07:41 +01:00
# Status of implementation
2018-01-13 15:49:46 +01:00
2018-03-05 12:12:58 +01:00
Feature complete as of Mastodon 2.2.0
2018-01-09 22:12:11 +01:00
* [x] GET /api/v1/accounts/:id
* [x] GET /api/v1/accounts/verify_credentials
2018-01-22 02:09:44 +01:00
* [x] PATCH /api/v1/accounts/update_credentials
2018-01-09 22:12:11 +01:00
* [x] GET /api/v1/accounts/:id/followers
* [x] GET /api/v1/accounts/:id/following
* [x] GET /api/v1/accounts/:id/statuses
2018-01-22 02:09:44 +01:00
* [x] POST /api/v1/accounts/:id/follow
* [x] POST /api/v1/accounts/:id/unfollow
* [x] POST /api/v1/accounts/:id/block
* [x] POST /api/v1/accounts/:id/unblock
* [x] POST /api/v1/accounts/:id/mute
* [x] POST /api/v1/accounts/:id/unmute
2018-01-09 22:12:11 +01:00
* [x] GET /api/v1/accounts/relationships
* [x] GET /api/v1/accounts/search
2018-01-22 02:09:44 +01:00
* [x] POST /api/v1/apps
2018-01-12 20:49:15 +01:00
* [x] GET /api/v1/blocks
* [x] GET /api/v1/domain_blocks
2018-01-22 02:09:44 +01:00
* [x] POST /api/v1/domain_blocks
2018-01-24 18:52:24 +01:00
* [x] DELETE /api/v1/domain_blocks
2018-01-12 20:49:15 +01:00
* [x] GET /api/v1/favourites
* [x] GET /api/v1/follow_requests
2018-01-22 02:09:44 +01:00
* [x] POST /api/v1/follow_requests/:id/authorize
* [x] POST /api/v1/follow_requests/:id/reject
* [x] POST /api/v1/follows
2018-01-12 20:49:15 +01:00
* [x] GET /api/v1/instance
* [x] GET /api/v1/custom_emojis
* [x] GET /api/v1/lists
* [x] GET /api/v1/accounts/:id/lists
* [x] GET /api/v1/lists/:id/accounts
* [x] GET /api/v1/lists/:id
2018-01-22 02:09:44 +01:00
* [x] POST /api/v1/lists
2018-01-24 18:52:24 +01:00
* [x] PUT /api/v1/lists/:id
* [x] DELETE /api/v1/lists/:id
2018-01-22 02:09:44 +01:00
* [x] POST /api/v1/lists/:id/accounts
2018-01-24 18:52:24 +01:00
* [x] DELETE /api/v1/lists/:id/accounts
2018-01-22 02:09:44 +01:00
* [x] POST /api/v1/media
2018-01-12 20:49:15 +01:00
* [x] GET /api/v1/mutes
* [x] GET /api/v1/notifications
* [x] GET /api/v1/notifications/:id
2018-01-22 02:09:44 +01:00
* [x] POST /api/v1/notifications/clear
* [x] POST /api/v1/notifications/dismiss
2018-01-12 20:49:15 +01:00
* [x] GET /api/v1/reports
2018-01-22 02:09:44 +01:00
* [x] POST /api/v1/reports
2018-01-12 20:49:15 +01:00
* [x] GET /api/v1/search
* [x] GET /api/v1/statuses/:id
* [x] GET /api/v1/statuses/:id/context
* [x] GET /api/v1/statuses/:id/card
* [x] GET /api/v1/statuses/:id/reblogged_by
* [x] GET /api/v1/statuses/:id/favourited_by
2018-01-22 02:09:44 +01:00
* [x] POST /api/v1/statuses
2018-01-24 18:52:24 +01:00
* [x] DELETE /api/v1/statuses/:id
2018-01-22 02:09:44 +01:00
* [x] POST /api/v1/statuses/:id/reblog
* [x] POST /api/v1/statuses/:id/unreblog
* [x] POST /api/v1/statuses/:id/favourite
* [x] POST /api/v1/statuses/:id/unfavourite
* [x] POST /api/v1/statuses/:id/pin
* [x] POST /api/v1/statuses/:id/unpin
* [x] POST /api/v1/statuses/:id/mute
* [x] POST /api/v1/statuses/:id/unmute
2018-01-12 20:49:15 +01:00
* [x] GET /api/v1/timelines/home
* [x] GET /api/v1/timelines/public
* [x] GET /api/v1/timelines/tag/:hashtag
* [x] GET /api/v1/timelines/list/:list_id
2018-02-26 07:57:30 +01:00
* [x] GET /api/v1/streaming/user
* [x] GET /api/v1/streaming/public
* [x] GET /api/v1/streaming/public/local
* [x] GET /api/v1/streaming/hashtag
* [x] GET /api/v1/streaming/list
2018-02-11 22:41:47 +01:00
2018-01-06 21:33:52 +01:00
# Copyright
2018-01-13 00:34:16 +01:00
2018-01-09 22:12:11 +01:00
Copyright © 2018 tastytea < tastytea @ tastytea . de > .
2018-01-06 21:33:52 +01:00
License GPLv3: GNU GPL version 3 < https: / / www . gnu . org / licenses / gpl-3 . 0 . html > .
This program comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.