Skip to content

Instantly share code, notes, and snippets.

@bcdejp
Created December 21, 2014 11:46
Show Gist options
  • Save bcdejp/036476ff6d895d820321 to your computer and use it in GitHub Desktop.
Save bcdejp/036476ff6d895d820321 to your computer and use it in GitHub Desktop.
Pythonでつぶやく
#!/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