230 lines
14 KiB
HTML
230 lines
14 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.14"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>mastodon-cpp: Main Page</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">mastodon-cpp
|
|
 <span id="projectnumber">0.20.0</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.14 -->
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(function() {
|
|
initMenu('',false,false,'search.php','Search');
|
|
});
|
|
/* @license-end */</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">mastodon-cpp Documentation</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="textblock"><p><b>mastodon-cpp</b> is a C++ wrapper for the Mastodon API. The library takes care of the network stuff. You submit a query and get the raw JSON. You can then put that JSON into easy to use classes.</p>
|
|
<p><a href="https://schlomp.space/tastytea/mastodon-cpp/milestones">TODO-list</a></p>
|
|
<p><b>The ABI will be unstable in versions < 1.0.0</b></p>
|
|
<h1>Usage</h1>
|
|
<p>The HTML reference can be generated with <code>build_doc.sh</code>, if doxygen is installed. It is also available at <a href="https://doc.schlomp.space/mastodon-cpp/annotated.html">doc.schlomp.space/mastodon-cpp/</a>. There are <a href="https://schlomp.space/tastytea/mastodon-cpp/src/branch/master/examples">examples</a> in <code>examples/</code>.</p>
|
|
<h2>Most basic example</h2>
|
|
<div class="fragment"><div class="line">{C++}</div><div class="line">#include <iostream></div><div class="line">#include <string></div><div class="line">#include <mastodon-cpp/mastodon-cpp.hpp></div><div class="line"></div><div class="line">int main()</div><div class="line">{</div><div class="line"> Mastodon::API masto("social.example.com", "auth_token");</div><div class="line"> std::string answer;</div><div class="line"> masto.get(Mastodon::API::v1::accounts_verify_credentials, answer);</div><div class="line"> std::cout << answer << '\n';</div><div class="line">}</div></div><!-- fragment --><h2>Another simple example</h2>
|
|
<p>Using the <code>Easy</code>-class.</p>
|
|
<div class="fragment"><div class="line">{C++}</div><div class="line">#include <iostream></div><div class="line">#include <string></div><div class="line">#include <vector></div><div class="line">#include <mastodon-cpp/mastodon-cpp.hpp></div><div class="line">#include <mastodon-cpp/easy/all.hpp></div><div class="line"></div><div class="line">using Mastodon::Easy;</div><div class="line"></div><div class="line">int main()</div><div class="line">{</div><div class="line"> Easy masto("social.example", "");</div><div class="line"> std::string answer;</div><div class="line"> masto.get(Mastodon::API::v1::timelines_public, answer);</div><div class="line"></div><div class="line"> for (const std::string &str : Easy::json_array_to_vector(answer))</div><div class="line"> {</div><div class="line"> Easy::Status status(str);</div><div class="line"> std::cout << " " << status.account().acct() << " wrote:\n";</div><div class="line"> std::cout << status.content() << '\n';</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><h2>Compiling your project</h2>
|
|
<p>A project consisting of one file can be compiled as follows:</p>
|
|
<div class="fragment"><div class="line">g++ -std=c++14 -lmastodon-cpp example.cpp</div></div><!-- fragment --><h2>Error codes</h2>
|
|
<p>mastodon-cpp will never use error codes below 11, except 0.</p>
|
|
<table class="markdownTable">
|
|
<tr class="markdownTableHead">
|
|
<th class="markdownTableHeadRight">Code </th><th class="markdownTableHeadLeft">Explanation </th></tr>
|
|
<tr class="markdownTableBody" class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyRight">0 </td><td class="markdownTableBodyLeft">No error </td></tr>
|
|
<tr class="markdownTableBody" class="markdownTableRowEven">
|
|
<td class="markdownTableBodyRight">11 </td><td class="markdownTableBodyLeft">Invalid call </td></tr>
|
|
<tr class="markdownTableBody" class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyRight">12 </td><td class="markdownTableBodyLeft">Not implemented </td></tr>
|
|
<tr class="markdownTableBody" class="markdownTableRowEven">
|
|
<td class="markdownTableBodyRight">13 </td><td class="markdownTableBodyLeft">URL changed (HTTP 301 or 308) </td></tr>
|
|
<tr class="markdownTableBody" class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyRight">14 </td><td class="markdownTableBodyLeft">Aborted by user </td></tr>
|
|
<tr class="markdownTableBody" class="markdownTableRowEven">
|
|
<td class="markdownTableBodyRight">15 </td><td class="markdownTableBodyLeft">Network error (curlpp exception) </td></tr>
|
|
<tr class="markdownTableBody" class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyRight">16 </td><td class="markdownTableBodyLeft">Timeout </td></tr>
|
|
<tr class="markdownTableBody" class="markdownTableRowEven">
|
|
<td class="markdownTableBodyRight">100 - 999 </td><td class="markdownTableBodyLeft">HTTP status codes </td></tr>
|
|
<tr class="markdownTableBody" class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyRight">65535 </td><td class="markdownTableBodyLeft">Unknown error </td></tr>
|
|
</table>
|
|
<p>If you use a debug build, you get more verbose error messages.</p>
|
|
<h2>Useful links</h2>
|
|
<ul>
|
|
<li>https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md "Mastodon API reference"</li>
|
|
<li>https://github.com/tootsuite/documentation/blob/master/Using-the-API/Streaming-API.md "Mastodon streaming API reference"</li>
|
|
</ul>
|
|
<h1>Install</h1>
|
|
<h2>Packages</h2>
|
|
<p>Every <a href="https://schlomp.space/tastytea/mastodon-cpp/releases">release</a> includes packages for the package managers of Debian and Red Hat. Gentoo packages are available in an overlay.</p>
|
|
<h3>Gentoo</h3>
|
|
<p>Add my <a href="https://schlomp.space/tastytea/overlay">repository</a> and install it from there.</p>
|
|
<div class="fragment"><div class="line">eselect repository enable tastytea</div><div class="line">echo 'dev-cpp/mastodon-cpp ~amd64' >> /etc/portage/package.keywords/mastodon-cpp</div><div class="line">emaint sync -r tastytea</div><div class="line">emerge -a dev-cpp/mastodon-cpp</div></div><!-- fragment --><h3>DEB and RPM</h3>
|
|
<p>Prebuilt DEB and RPM packages for x86_64(amd64) are provided with each release. These packages are automatically built and not tested. Install with <code>dpkg -i</code> or <code>rpm -i</code>, respectively.</p>
|
|
<p>To use the DEB package on stretch, you will need <a href="https://packages.debian.org/libcurlpp0">libcurlpp0</a> from sid.</p>
|
|
<h2>From source</h2>
|
|
<h3>Dependencies</h3>
|
|
<ul>
|
|
<li>Tested OS: Linux</li>
|
|
<li>C++ compiler (tested: gcc 5 / 6 / 7 / 8)</li>
|
|
<li><a href="https://cmake.org/">cmake</a> (tested: 3.9 / 3.12)</li>
|
|
<li><a href="https://pkgconfig.freedesktop.org/wiki/">pkgconfig</a> (tested: 0.29)</li>
|
|
<li><a href="http://www.curlpp.org/">curlpp</a> (tested: 0.8)</li>
|
|
<li>Optional<ul>
|
|
<li>Easy interface & Examples: <a href="https://github.com/open-source-parsers/jsoncpp">jsoncpp</a> (tested: 1.8 / 1.7)</li>
|
|
<li>Documentation: <a href="https://www.stack.nl/~dimitri/doxygen/">doxygen</a> (tested: 1.8)</li>
|
|
<li>DEB package: <a href="https://packages.qa.debian.org/dpkg">dpkg</a> (tested: 1.19 / 1.18)</li>
|
|
<li>RPM package: <a href="http://www.rpm.org">rpm</a> (tested: 4.14 / 4.12)</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<h3>Get sourcecode</h3>
|
|
<h4>Release</h4>
|
|
<p>Download the current release at <a href="https://schlomp.space/tastytea/mastodon-cpp/releases">schlomp.space</a>.</p>
|
|
<h4>Development version</h4>
|
|
<div class="fragment"><div class="line">git clone https://schlomp.space/tastytea/mastodon-cpp.git</div></div><!-- fragment --><h3>Compile</h3>
|
|
<div class="fragment"><div class="line">mkdir build</div><div class="line">cd build/</div><div class="line">cmake ..</div><div class="line">make</div></div><!-- fragment --><p>cmake options:</p>
|
|
<ul>
|
|
<li><code>-DCMAKE_BUILD_TYPE=Debug</code> for a debug build</li>
|
|
<li><code>-DWITHOUT_EASY=ON</code> to not build the Easy abstractions and to get rid of the jsoncpp-dependency (not recommended)</li>
|
|
<li><code>-DWITH_EXAMPLES=ON</code> if you want to compile the examples</li>
|
|
<li><code>-DWITH_TESTS=ON</code> if you want to compile the tests</li>
|
|
<li><code>-DWITH_STATIC=ON</code> If you want a static library along with the dynamic one</li>
|
|
<li><code>-DWITH_DOC=ON</code> if you want to compile the HTML reference</li>
|
|
<li><code>-DWITH_DEB=ON</code> if you want to be able to generate a deb-package</li>
|
|
<li><code>-DWITH_RPM=ON</code> if you want to be able to generate an rpm-package</li>
|
|
</ul>
|
|
<p>You can run the tests with <code>ctest ..</code> inside the build directory. To install, run <code>make install</code>.</p>
|
|
<h3>Packages</h3>
|
|
<h4>DEB and RPM</h4>
|
|
<p>Compile with <code>-DWITH_DEB=ON</code> or <code>-DWITH_RPM=ON</code>. Run <code>make package</code> from the build directory to generate a DEB/RPM package.</p>
|
|
<h4>Other</h4>
|
|
<p>Run <code>make package</code> from the build directory to generate a tar.gz archive.</p>
|
|
<h1>Status of implementation</h1>
|
|
<p>Feature complete as of Mastodon 2.6.1</p>
|
|
<ul>
|
|
<li>[x] GET /api/v1/accounts/:id</li>
|
|
<li>[x] GET /api/v1/accounts/verify_credentials</li>
|
|
<li>[x] PATCH /api/v1/accounts/update_credentials</li>
|
|
<li>[x] GET /api/v1/accounts/:id/followers</li>
|
|
<li>[x] GET /api/v1/accounts/:id/following</li>
|
|
<li>[x] GET /api/v1/accounts/:id/statuses</li>
|
|
<li>[x] POST /api/v1/accounts/:id/follow</li>
|
|
<li>[x] POST /api/v1/accounts/:id/unfollow</li>
|
|
<li>[x] POST /api/v1/accounts/:id/block</li>
|
|
<li>[x] POST /api/v1/accounts/:id/unblock</li>
|
|
<li>[x] POST /api/v1/accounts/:id/mute</li>
|
|
<li>[x] POST /api/v1/accounts/:id/unmute</li>
|
|
<li>[x] GET /api/v1/accounts/relationships</li>
|
|
<li>[x] GET /api/v1/accounts/search</li>
|
|
<li>[x] POST /api/v1/apps</li>
|
|
<li>[x] GET /api/v1/blocks</li>
|
|
<li>[x] GET /api/v1/domain_blocks</li>
|
|
<li>[x] POST /api/v1/domain_blocks</li>
|
|
<li>[x] DELETE /api/v1/domain_blocks</li>
|
|
<li>[x] GET /api/v1/endorsements</li>
|
|
<li>[x] POST /api/v1/accounts/:id/pin</li>
|
|
<li>[x] POST /api/v1/accounts/:id/unpin</li>
|
|
<li>[x] GET /api/v1/favourites</li>
|
|
<li>[x] GET /api/v1/follow_requests</li>
|
|
<li>[x] POST /api/v1/follow_requests/:id/authorize</li>
|
|
<li>[x] POST /api/v1/follow_requests/:id/reject</li>
|
|
<li>[x] POST /api/v1/follows</li>
|
|
<li>[x] GET /api/v1/instance</li>
|
|
<li>[x] GET /api/v1/custom_emojis</li>
|
|
<li>[x] GET /api/v1/lists</li>
|
|
<li>[x] GET /api/v1/accounts/:id/lists</li>
|
|
<li>[x] GET /api/v1/lists/:id/accounts</li>
|
|
<li>[x] GET /api/v1/lists/:id</li>
|
|
<li>[x] POST /api/v1/lists</li>
|
|
<li>[x] PUT /api/v1/lists/:id</li>
|
|
<li>[x] DELETE /api/v1/lists/:id</li>
|
|
<li>[x] POST /api/v1/lists/:id/accounts</li>
|
|
<li>[x] DELETE /api/v1/lists/:id/accounts</li>
|
|
<li>[x] POST /api/v1/media</li>
|
|
<li>[x] PUT /api/v1/media/:id</li>
|
|
<li>[x] GET /api/v1/mutes</li>
|
|
<li>[x] GET /api/v1/notifications</li>
|
|
<li>[x] GET /api/v1/notifications/:id</li>
|
|
<li>[x] POST /api/v1/notifications/clear</li>
|
|
<li>[x] POST /api/v1/notifications/dismiss</li>
|
|
<li>[x] GET /api/v1/reports</li>
|
|
<li>[x] POST /api/v1/reports</li>
|
|
<li>[x] GET /api/v1/search</li>
|
|
<li>[x] GET /api/v1/statuses/:id</li>
|
|
<li>[x] GET /api/v1/statuses/:id/context</li>
|
|
<li>[x] GET /api/v1/statuses/:id/card</li>
|
|
<li>[x] GET /api/v1/statuses/:id/reblogged_by</li>
|
|
<li>[x] GET /api/v1/statuses/:id/favourited_by</li>
|
|
<li>[x] POST /api/v1/statuses</li>
|
|
<li>[x] DELETE /api/v1/statuses/:id</li>
|
|
<li>[x] POST /api/v1/statuses/:id/reblog</li>
|
|
<li>[x] POST /api/v1/statuses/:id/unreblog</li>
|
|
<li>[x] POST /api/v1/statuses/:id/favourite</li>
|
|
<li>[x] POST /api/v1/statuses/:id/unfavourite</li>
|
|
<li>[x] POST /api/v1/statuses/:id/pin</li>
|
|
<li>[x] POST /api/v1/statuses/:id/unpin</li>
|
|
<li>[x] POST /api/v1/statuses/:id/mute</li>
|
|
<li>[x] POST /api/v1/statuses/:id/unmute</li>
|
|
<li>[x] GET /api/v1/timelines/home</li>
|
|
<li>[x] GET /api/v1/timelines/public</li>
|
|
<li>[x] GET /api/v1/timelines/tag/:hashtag</li>
|
|
<li>[x] GET /api/v1/timelines/list/:list_id</li>
|
|
<li>[x] GET /api/v1/streaming/user</li>
|
|
<li>[x] GET /api/v1/streaming/public</li>
|
|
<li>[x] GET /api/v1/streaming/public/local</li>
|
|
<li>[x] GET /api/v1/streaming/hashtag</li>
|
|
<li>[x] GET /api/v1/streaming/list</li>
|
|
<li>[x] POST /api/v1/push/subscription</li>
|
|
<li>[x] GET /api/v1/push/subscription</li>
|
|
<li>[x] PUT /api/v1/push/subscription</li>
|
|
<li>[x] DELETE /api/v1/push/subscription</li>
|
|
<li>[x] GET /api/v2/search</li>
|
|
</ul>
|
|
<h2>Glitch-Soc support</h2>
|
|
<ul>
|
|
<li>[x] max_toot_chars in /api/v1/instance</li>
|
|
<li>[x] GET /api/v1/bookmarks</li>
|
|
<li>[x] POST /api/v1/statuses/:id/bookmark</li>
|
|
<li>[x] POST /api/v1/statuses/:id/unbookmark</li>
|
|
</ul>
|
|
<h1>Copyright</h1>
|
|
<div class="fragment"><div class="line">Copyright © 2018 tastytea <tastytea@tastytea.de>.</div><div class="line">License GPLv3: GNU GPL version 3 <https://www.gnu.org/licenses/gpl-3.0.html>.</div><div class="line">This program comes with ABSOLUTELY NO WARRANTY. This is free software,</div><div class="line">and you are welcome to redistribute it under certain conditions.</div></div><!-- fragment --> </div></div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.14
|
|
</small></address>
|
|
</body>
|
|
</html>
|