forked from wong2/Save2Weibo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
29 lines (24 loc) · 714 Bytes
/
bot.py
File metadata and controls
29 lines (24 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#-*-coding:utf-8-*-
from config import *
from weibopy.auth import OAuthHandler
from weibopy.api import API
from weibopy.error import WeibopError
class Bot:
def __init__(self):
BACK_URL = ""
#验证开发者密钥.
auth = OAuthHandler( APP_KEY, APP_SECRET, BACK_URL )
auth.setToken( BOT_TOKEN_KEY, BOT_TOKEN_SECRET )
self.api = API(auth)
def send(self, message):
try:
return self.api.update_status(message)
except WeibopError, e:
return self.api.user_timeline(count=1)[0]
if __name__ == "__main__":
bot = Bot()
try:
s = bot.send("Hello World")
print s
except:
print "error"