-
Notifications
You must be signed in to change notification settings - Fork 3
/
sendweibo.py
executable file
·53 lines (45 loc) · 1.24 KB
/
sendweibo.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Feb 15, 2014
@author: honghe
API调用示例
"""
from initclient import initclient
def postweibo():
client = initclient.get_client()
if not client:
print 'Get client Error!'
return
# 发微博
while True:
print 'Do you want to send a new weibo?(y/n):',
choice = raw_input()
if choice in ['y','Y']:
content = raw_input('Input new weibo content:')
if content:
client.statuses.update.post(status = content)
print 'Send succesfully!'
break;
else:
print 'Error! Empty content!'
if choice in ['n', 'N']:
break
def fetch_public_timeline():
client = initclient.get_client()
if not client:
print 'Get client Error!'
return
r = client.statuses.public_timeline.get(count=20)
for st in r.statuses:
print st.text
def fetch_user_timeline():
client = initclient.get_client()
if not client:
print 'Get client Error!'
return
r = client.statuses.user_timeline.get()
for st in r.statuses:
print st.text
if __name__ == '__main__':
fetch_public_timeline()