Last active
December 17, 2015 10:49
-
-
Save ranlix/5597809 to your computer and use it in GitHub Desktop.
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
# coding=utf-8 | |
import time | |
from datetime import datetime | |
from douban_client import DoubanClient | |
LAST_MINUTE = 59 # when it is the last mintue in an hour,the minute is (60-1) | |
MINUTE_SECONDS = 60 # one minute has 60s | |
API_KEY = 'your api key' | |
API_SECRET = 'your api secret' | |
SCOPE = 'douban_basic_common,shuo_basic_r,shuo_basic_w' | |
client = DoubanClient(API_KEY, API_SECRET, 'https://douban.com', SCOPE) | |
print 'Go to the following link in your browser:' | |
print client.authorize_url | |
code = raw_input('Enter the verification code:') | |
client.auth_with_code(code) | |
print client.auth_with_token(client.token_code) | |
def main(): | |
'''This is a main function to print bell when time is the whole point.''' | |
if time.localtime().tm_min == 1: # LAST_MINUTE: | |
# when the minute is 59, the sleep time is not 60s any more | |
time.sleep(MINUTE_SECONDS-time.localtime().tm_sec) | |
client.miniblog.new( "当!"*int(datetime.now().strftime("%I"))) | |
else: | |
time.sleep(MINUTE_SECONDS) |
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
>>> ================================ RESTART ================================ | |
>>> | |
Go to the following link in your browser: | |
https://www.douban.com/service/auth2/auth?scope=douban_basic_**************************** | |
Enter the verification code:************** | |
None | |
while 1: | |
if __name__ == '__main__':main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
错误信息贴一下。
另外不要把你的
API_KEY
,API_SECRET
暴露到公共场合,代码规范一下: