diff options
author | Lorenz Diener <[email protected]> | 2018-11-26 10:50:54 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2018-11-26 10:50:54 +0100 |
commit | e1e003ec762e126338032193ec7a70df659512a4 (patch) | |
tree | a5c058494afdea00590c2565849275281706cba8 | |
parent | 191ad84cef0b37e8d8a708812336858d447304c5 (diff) | |
parent | dc4b3ffc03c3724c09862bb114736786a0679032 (diff) | |
download | mastodon.py-e1e003ec762e126338032193ec7a70df659512a4.tar.gz |
Merge pull request #143 from MarkEEaton/master
Revise sample code in README.rst
-rw-r--r-- | README.rst | 19 | ||||
-rw-r--r-- | docs/index.rst | 21 |
2 files changed, 29 insertions, 11 deletions
@@ -1,10 +1,11 @@ | |||
1 | Mastodon.py | 1 | Mastodon.py |
2 | =========== | 2 | =========== |
3 | Register your app! This only needs to be done once. Uncomment the code and substitute in your information. | ||
4 | |||
3 | .. code-block:: python | 5 | .. code-block:: python |
4 | 6 | ||
5 | from mastodon import Mastodon | 7 | from mastodon import Mastodon |
6 | 8 | ||
7 | # Register app - only once! | ||
8 | ''' | 9 | ''' |
9 | Mastodon.create_app( | 10 | Mastodon.create_app( |
10 | 'pytooterapp', | 11 | 'pytooterapp', |
@@ -13,8 +14,12 @@ Mastodon.py | |||
13 | ) | 14 | ) |
14 | ''' | 15 | ''' |
15 | 16 | ||
16 | # Log in - either every time, or use persisted | 17 | Then login. This can be done every time, or use persisted. |
17 | ''' | 18 | |
19 | .. code-block:: python | ||
20 | |||
21 | from mastodon import Mastodon | ||
22 | |||
18 | mastodon = Mastodon( | 23 | mastodon = Mastodon( |
19 | client_id = 'pytooter_clientcred.secret', | 24 | client_id = 'pytooter_clientcred.secret', |
20 | api_base_url = 'https://mastodon.social' | 25 | api_base_url = 'https://mastodon.social' |
@@ -24,9 +29,13 @@ Mastodon.py | |||
24 | 'incrediblygoodpassword', | 29 | 'incrediblygoodpassword', |
25 | to_file = 'pytooter_usercred.secret' | 30 | to_file = 'pytooter_usercred.secret' |
26 | ) | 31 | ) |
27 | ''' | ||
28 | 32 | ||
29 | # Create actual API instance | 33 | To post, create an actual API instance. |
34 | |||
35 | .. code-block:: python | ||
36 | |||
37 | from mastodon import Mastodon | ||
38 | |||
30 | mastodon = Mastodon( | 39 | mastodon = Mastodon( |
31 | access_token = 'pytooter_usercred.secret', | 40 | access_token = 'pytooter_usercred.secret', |
32 | api_base_url = 'https://mastodon.social' | 41 | api_base_url = 'https://mastodon.social' |
diff --git a/docs/index.rst b/docs/index.rst index 0cff37e..808e563 100644 --- a/docs/index.rst +++ b/docs/index.rst | |||
@@ -2,12 +2,13 @@ Mastodon.py | |||
2 | =========== | 2 | =========== |
3 | .. py:module:: mastodon | 3 | .. py:module:: mastodon |
4 | .. py:class: Mastodon | 4 | .. py:class: Mastodon |
5 | |||
6 | Register your app! This only needs to be done once. Uncomment the code and substitute in your information. | ||
5 | 7 | ||
6 | .. code-block:: python | 8 | .. code-block:: python |
7 | 9 | ||
8 | from mastodon import Mastodon | 10 | from mastodon import Mastodon |
9 | 11 | ||
10 | # Register app - only once! | ||
11 | ''' | 12 | ''' |
12 | Mastodon.create_app( | 13 | Mastodon.create_app( |
13 | 'pytooterapp', | 14 | 'pytooterapp', |
@@ -16,8 +17,12 @@ Mastodon.py | |||
16 | ) | 17 | ) |
17 | ''' | 18 | ''' |
18 | 19 | ||
19 | # Log in - either every time, or use persisted | 20 | Then login. This can be done every time, or use persisted. |
20 | ''' | 21 | |
22 | .. code-block:: python | ||
23 | |||
24 | from mastodon import Mastodon | ||
25 | |||
21 | mastodon = Mastodon( | 26 | mastodon = Mastodon( |
22 | client_id = 'pytooter_clientcred.secret', | 27 | client_id = 'pytooter_clientcred.secret', |
23 | api_base_url = 'https://mastodon.social' | 28 | api_base_url = 'https://mastodon.social' |
@@ -27,14 +32,18 @@ Mastodon.py | |||
27 | 'incrediblygoodpassword', | 32 | 'incrediblygoodpassword', |
28 | to_file = 'pytooter_usercred.secret' | 33 | to_file = 'pytooter_usercred.secret' |
29 | ) | 34 | ) |
30 | ''' | ||
31 | 35 | ||
32 | # Create actual API instance | 36 | To post, create an actual API instance. |
37 | |||
38 | .. code-block:: python | ||
39 | |||
40 | from mastodon import Mastodon | ||
41 | |||
33 | mastodon = Mastodon( | 42 | mastodon = Mastodon( |
34 | access_token = 'pytooter_usercred.secret', | 43 | access_token = 'pytooter_usercred.secret', |
35 | api_base_url = 'https://mastodon.social' | 44 | api_base_url = 'https://mastodon.social' |
36 | ) | 45 | ) |
37 | mastodon.toot('Tooting from python using #mastodonpy !') | 46 | mastodon.toot('Tooting from python using #mastodonpy !') |
38 | 47 | ||
39 | `Mastodon`_ is an ActivityPub and OStatus based twitter-like federated social | 48 | `Mastodon`_ is an ActivityPub and OStatus based twitter-like federated social |
40 | network node. It has an API that allows you to interact with its | 49 | network node. It has an API that allows you to interact with its |