Created
December 21, 2014 11:46
-
-
Save bcdejp/036476ff6d895d820321 to your computer and use it in GitHub Desktop.
Pythonでつぶやく
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from requests_oauthlib import OAuth1Session | |
#CK = 'XXXXXXXXXXXXXXXXXXXXXX' # Consumer Key | |
#CS = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # Consumer Secret | |
#AT = 'XXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # Access Token | |
#AS = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # Accesss Token Secert | |
# ツイート投稿用のURL | |
URL = "https://api.twitter.com/1.1/statuses/update.json" | |
def tweet(text): | |
#Tweetを作成 | |
params = {"status": text} | |
# OAuth認証して、POSTで投稿 | |
twitter = OAuth1Session(CK, CS, AT, AS) | |
req = twitter.post(URL, params = params) | |
#レスポンスコードを返す | |
return req.status_code | |
if __name__ == '__main__': | |
# ツイート | |
print tweet("Hello World!!!!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment