Last active
April 15, 2017 19:49
-
-
Save mneko22/3fa59e63026ae4d12d14ec2dc0f44941 to your computer and use it in GitHub Desktop.
mastodon.py toot sample for mstdn.jp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """This is a test program.""" | |
| from mastodon import Mastodon | |
| import os | |
| CLIENT_ID = 'c9ce278f74a48920e487ca103ca2970f5e6bb6d54566f151bffb87ad84906303' | |
| CLIENT_SECRET = '7ddd75db55213ed242b805459686df434d2335842d5855bc18eb0d7dc567f004' | |
| API_SERVER = 'https://mstdn.jp/' | |
| def init(): | |
| ''' init ''' | |
| if os.path.isfile('pytooter_usercred.txt'): | |
| with open('pytooter_usercred.txt', 'r') as token_file: | |
| _user_token = token_file.readline().rstrip() | |
| return Mastodon(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, | |
| api_base_url=API_SERVER, access_token=_user_token) | |
| else: | |
| mastodon = Mastodon(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, | |
| api_base_url=API_SERVER) | |
| user_mail = input('user_email: ') | |
| user_passwd = input('password: ') | |
| mastodon.log_in( | |
| user_mail, | |
| user_password, | |
| to_file='pytooter_usercred.txt' | |
| ) | |
| return mastodon | |
| def main(): | |
| ''' toto ''' | |
| instance = init() | |
| content = input("->") | |
| instance.toot(content) | |
| if __name__ == '__main__': | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Mastodon.py==1.0.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment