Last active
August 29, 2015 14:07
-
-
Save syachi/dc477338657176f69495 to your computer and use it in GitHub Desktop.
pythonからtwitterにpostする。
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 -*- | |
# See http://qiita.com/yubais/items/dd143fe608ccad8e9f85 | |
import sys | |
import datetime | |
import requests_oauthlib | |
# 残り日数 | |
td = datetime.date(2014, 11, 15) - datetime.date.today() | |
if td.days < 1: | |
sys.exit("Error: The date has already passed") | |
CK = 'dummy' # Consumer key | |
CS = 'dummy' # Consumer secret | |
AT = 'dummy' # Access token | |
AS = 'dummy' # Accesss token secert | |
url = "https://api.twitter.com/1.1/statuses/update.json" | |
msg = "【定期ポスト】北海道データベースDAYまであと{}日" \ | |
" http://www.infiniteloop.co.jp/blog/2014/10/hokkaidodbday/".format(td.days) | |
tw = requests_oauthlib.OAuth1Session(CK, CS, AT, AS) | |
req = tw.post(url, params={"status": msg}) | |
if req.status_code != 200: | |
sys.exit("Error: {}".format(req.status_code)) | |
sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment