177 lines
No EOL
9.1 KiB
HTML
177 lines
No EOL
9.1 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/html; charset=utf-8" />
|
|
|
|
<title>Basic Usage — Twython 3.0.0 documentation</title>
|
|
|
|
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
|
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: '../',
|
|
VERSION: '3.0.0',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
<link rel="top" title="Twython 3.0.0 documentation" href="../index.html" />
|
|
<link rel="next" title="Developer Interface" href="../api.html" />
|
|
<link rel="prev" title="Starting Out" href="starting_out.html" />
|
|
</head>
|
|
<body>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
accesskey="I">index</a></li>
|
|
<li class="right" >
|
|
<a href="../py-modindex.html" title="Python Module Index"
|
|
>modules</a> |</li>
|
|
<li class="right" >
|
|
<a href="../api.html" title="Developer Interface"
|
|
accesskey="N">next</a> |</li>
|
|
<li class="right" >
|
|
<a href="starting_out.html" title="Starting Out"
|
|
accesskey="P">previous</a> |</li>
|
|
<li><a href="../index.html">Twython 3.0.0 documentation</a> »</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body">
|
|
|
|
<div class="section" id="basic-usage">
|
|
<span id="id1"></span><h1>Basic Usage<a class="headerlink" href="#basic-usage" title="Permalink to this headline">¶</a></h1>
|
|
<p>This section will cover how to use Twython and interact with some basic Twitter API calls</p>
|
|
<p>Before you make any API calls, make sure you <a class="reference internal" href="starting_out.html#starting-out"><em>authenticated</em></a> the user!</p>
|
|
<p>Create a Twython instance with your application keys and the users OAuth tokens:</p>
|
|
<div class="highlight-python"><pre>from twython import Twython
|
|
twitter = Twython(APP_KEY, APP_SECRET
|
|
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)</pre>
|
|
</div>
|
|
<div class="admonition-important admonition">
|
|
<p class="first admonition-title">Important</p>
|
|
<p class="last">All sections on this page will assume you’re using a Twython instance</p>
|
|
</div>
|
|
<div class="section" id="what-twython-returns">
|
|
<h2>What Twython Returns<a class="headerlink" href="#what-twython-returns" title="Permalink to this headline">¶</a></h2>
|
|
<p>Twython returns a dictionary of JSON response from Twitter</p>
|
|
</div>
|
|
<div class="section" id="user-information">
|
|
<h2>User Information<a class="headerlink" href="#user-information" title="Permalink to this headline">¶</a></h2>
|
|
<p>Documentation: <a class="reference external" href="https://dev.twitter.com/docs/api/1.1/get/account/verify_credentials">https://dev.twitter.com/docs/api/1.1/get/account/verify_credentials</a></p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">twitter</span><span class="o">.</span><span class="n">verify_credentials</span><span class="p">()</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="authenticated-users-home-timeline">
|
|
<h2>Authenticated Users Home Timeline<a class="headerlink" href="#authenticated-users-home-timeline" title="Permalink to this headline">¶</a></h2>
|
|
<p>Documentation: <a class="reference external" href="https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline">https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline</a></p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">twitter</span><span class="o">.</span><span class="n">get_home_timeline</span><span class="p">()</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="search">
|
|
<h2>Search<a class="headerlink" href="#search" title="Permalink to this headline">¶</a></h2>
|
|
<p>Documentation: <a class="reference external" href="https://dev.twitter.com/docs/api/1.1/get/search/tweets">https://dev.twitter.com/docs/api/1.1/get/search/tweets</a></p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">twitter</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">q</span><span class="o">=</span><span class="s">'python'</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>To help explain <a class="reference internal" href="starting_out.html#starting-out"><em>dynamic function arguments</em></a> a little more, you can see that the previous call used the keyword argument <tt class="docutils literal"><span class="pre">q</span></tt>, that is because Twitter specifies in their <a class="reference external" href="https://dev.twitter.com/docs/api/1.1/get/search/tweets">search documentation</a> that the search call accepts the parameter “q”. You can pass mutiple keyword arguments. The search documentation also specifies that the call accepts the parameter “result_type”</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">twitter</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">q</span><span class="o">=</span><span class="s">'python'</span><span class="p">,</span> <span class="n">result_type</span><span class="o">=</span><span class="s">'popular'</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="updating-status">
|
|
<h2>Updating Status<a class="headerlink" href="#updating-status" title="Permalink to this headline">¶</a></h2>
|
|
<p>Documentation: <a class="reference external" href="https://dev.twitter.com/docs/api/1/post/statuses/update">https://dev.twitter.com/docs/api/1/post/statuses/update</a></p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">twitter</span><span class="o">.</span><span class="n">update_status</span><span class="p">(</span><span class="n">status</span><span class="o">=</span><span class="s">'See how easy using Twython is!'</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar">
|
|
<div class="sphinxsidebarwrapper">
|
|
<h3><a href="../index.html">Table Of Contents</a></h3>
|
|
<ul>
|
|
<li><a class="reference internal" href="#">Basic Usage</a><ul>
|
|
<li><a class="reference internal" href="#what-twython-returns">What Twython Returns</a></li>
|
|
<li><a class="reference internal" href="#user-information">User Information</a></li>
|
|
<li><a class="reference internal" href="#authenticated-users-home-timeline">Authenticated Users Home Timeline</a></li>
|
|
<li><a class="reference internal" href="#search">Search</a></li>
|
|
<li><a class="reference internal" href="#updating-status">Updating Status</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
<h4>Previous topic</h4>
|
|
<p class="topless"><a href="starting_out.html"
|
|
title="previous chapter">Starting Out</a></p>
|
|
<h4>Next topic</h4>
|
|
<p class="topless"><a href="../api.html"
|
|
title="next chapter">Developer Interface</a></p>
|
|
<h3>This Page</h3>
|
|
<ul class="this-page-menu">
|
|
<li><a href="../_sources/usage/basic_usage.txt"
|
|
rel="nofollow">Show Source</a></li>
|
|
</ul>
|
|
<div id="searchbox" style="display: none">
|
|
<h3>Quick search</h3>
|
|
<form class="search" action="../search.html" method="get">
|
|
<input type="text" name="q" />
|
|
<input type="submit" value="Go" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
<p class="searchtip" style="font-size: 90%">
|
|
Enter search terms or a module, class or function name.
|
|
</p>
|
|
</div>
|
|
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
>index</a></li>
|
|
<li class="right" >
|
|
<a href="../py-modindex.html" title="Python Module Index"
|
|
>modules</a> |</li>
|
|
<li class="right" >
|
|
<a href="../api.html" title="Developer Interface"
|
|
>next</a> |</li>
|
|
<li class="right" >
|
|
<a href="starting_out.html" title="Starting Out"
|
|
>previous</a> |</li>
|
|
<li><a href="../index.html">Twython 3.0.0 documentation</a> »</li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer">
|
|
© Copyright 2013, Ryan McGrath.
|
|
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2b1.
|
|
</div>
|
|
</body>
|
|
</html> |