This repository has been archived on 2020-05-10. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon-cpp/docs/example15_proxy_8cpp-exampl...

55 lines
5.3 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: example15_proxy.cpp</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
&#160;<span id="projectnumber">0.30.1</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&amp;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">example15_proxy.cpp</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><span class="comment">/* This file is part of mastodon-cpp.</span></div><div class="line"><span class="comment"> * This example shows how to use a proxy.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;cstdint&gt;</span></div><div class="line"><span class="preprocessor">#ifdef MASTODON_CPP</span></div><div class="line"><span class="preprocessor"> #include &quot;mastodon-cpp.hpp&quot;</span></div><div class="line"><span class="preprocessor">#else</span></div><div class="line"><span class="preprocessor"> #include &lt;mastodon-cpp/mastodon-cpp.hpp&gt;</span></div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line"><span class="keyword">using</span> std::cout;</div><div class="line"><span class="keyword">using</span> <a name="_a0"></a><a class="code" href="classMastodon_1_1API.html">Mastodon::API</a>;</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> (argc &lt; 3)</div><div class="line"> {</div><div class="line"> std::cerr &lt;&lt; <span class="stringliteral">&quot;usage: &quot;</span> &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">&quot; &lt;instance&gt; &lt;access token&gt;\n&quot;</span>;</div><div class="line"> <span class="keywordflow">return</span> 1;</div><div class="line"> }</div><div class="line"></div><div class="line"> <a class="code" href="classMastodon_1_1API.html">Mastodon::API</a> masto(argv[1], argv[2]);</div><div class="line"> <span class="comment">// SOCKS5 Proxy. Proxy resolves URL hostname.</span></div><div class="line"> masto.<a name="a1"></a><a class="code" href="classMastodon_1_1API.html#a980009607243247a1295468a7adcd43c">set_proxy</a>(<span class="stringliteral">&quot;socks5h://[fd12::1a]:1080/&quot;</span>);</div><div class="line"> <span class="comment">// HTTPS proxy with username and password</span></div><div class="line"> masto.<a class="code" href="classMastodon_1_1API.html#a980009607243247a1295468a7adcd43c">set_proxy</a>(<span class="stringliteral">&quot;https://localhost:3128&quot;</span>, <span class="stringliteral">&quot;user5:supersecurepassword&quot;</span>);</div><div class="line"> std::string answer;</div><div class="line"> std::uint16_t ret;</div><div class="line"></div><div class="line"> ret = masto.<a name="a2"></a><a class="code" href="classMastodon_1_1API.html#ae42bb8841ebead64dbb555cb6284784e">get</a>(API::v1::accounts_verify_credentials, answer);</div><div class="line"></div><div class="line"> cout &lt;&lt; <span class="stringliteral">&quot;Return code: &quot;</span> &lt;&lt; ret &lt;&lt; <span class="charliteral">&#39;\n&#39;</span>;</div><div class="line"> std::cout &lt;&lt; answer &lt;&lt; <span class="charliteral">&#39;\n&#39;</span>;</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>