-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.py
220 lines (174 loc) · 5.7 KB
/
test.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import twoauth
if __name__ == "__main__":
import sys
api = twoauth.api(
sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
timeline = True
status = False
user = False
lists = False
dm = False
friendship = False
account = False
favorites = False
block = False
print "screen_name:", api.user["screen_name"]
if timeline:
print "Timeline:"
for tl in (api.public_timeline(),
api.home_timeline(),
api.friends_timeline(),
api.user_timeline(),
api.mentions(),
api.rt_by_me(),
api.rt_to_me(),
api.rt_of_me()):
print len(tl)
for s in tl:
#print "[%d] %15s: %s" % (
# s["id"], s["user"]["screen_name"], s["text"])
print "%s\n%s" % (
s.user.screen_name, s.text)
raw_input()
if status:
print "Status:"
print api.status_show(6309158646)["text"]
print "What are you doing?:",
post = raw_input()
postid = api.status_update(post)["id"]
print postid
raw_input()
api.status_destroy(postid)
print "Destroy!!"
try:
api.status_retweet(6768575868)
except Exception, e:
print e.read()
print "ReTweet!!"
for s in api.status_retweets(6305546787):
print s["user"]["screen_name"]
raw_input()
if user:
print "User:"
print api.user_show("hktechno")["status"]["text"]
tls = (api.user_search("python"),
api.status_friends(),
api.status_followers())
for tl in tls:
for s in tl:
print s["screen_name"]
raw_input()
if lists:
print "Lists:"
print "Create:",
li = api.lists_create("testlist", mode = "private",
description = "testtest")
lid = int(li["id"])
print lid, li["full_name"]
raw_input()
print "Update:",
li = api.lists_update("testlist", name = "hogehoge",
mode = "private", description = "hoge")
print li["id"], li["full_name"]
raw_input()
print "Index:"
for l in api.lists_index("hktechno")["lists"]:
print l["full_name"]
print "Show:",
li = api.lists_show("team", "twitter")
print li["full_name"], li["subscriber_count"], li["member_count"]
print "Destroy:",
print api.lists_destroy(lid)["id"]
raw_input()
print "Statuses:"
for l in api.lists_statuses("team", "twitter", count = "10"):
print "%20s %s" % (l["user"]["screen_name"], l["text"])
print "Memberships:"
for l in api.lists_memberships("hktechno")["lists"]:
print "%30s %s" % (l["full_name"], l["member_count"])
print "Subscriptions:"
for l in api.lists_subscriptions("hktechno")["lists"]:
print "%30s %s" % (l["full_name"], l["member_count"])
raw_input()
print "Members Show:"
for u in api.lists_mlist("team", "twitter")["users"]:
print u["screen_name"]
print "Subscribers Show:"
for u in api.lists_slist("team", "twitter")["users"]:
print u["screen_name"]
raw_input()
if dm:
print "Direct Message"
print "Inbox:"
for dm in api.dm_list():
print dm["text"]
print "Sent:"
for dm in api.dm_sent():
print dm["text"]
print "Send:"
dm = api.dm_new("hktechno", "hello")
raw_input()
print "Destroy:"
api.dm_destroy(dm["id"])
raw_input()
if friendship:
print "Friendships:"
print "Create:"
api.friends_create("hktechno")
print "Exists:"
print api.friends_exists(api.user["id"], "hktechno")
raw_input()
print "Destroy:"
api.friends_destroy("hktechno")
print "Show:"
print api.friends_show("hktechno")
raw_input()
print "Friends ids:"
for id in api.friends_ids("hktechno"):
print int(id)
print "Followers ids:"
for id in api.followers_ids():
print int(id)
if account:
print "Account:"
print "Verify Credentials:"
a = api.verify_credentials()
print a["id"]
print a["name"]
print a["screen_name"]
print a["status"]["text"]
print "Rate Limit:"
print api.rate_limit(), api.rate_limit(True)
print "End Session:"
print api.end_session()
raw_input()
print "Update profile colors:"
c = eval("0x" + a["profile_background_color"])
c = 0xffffff - c
c = "%06x" % c
try:
api.profile_colors(profile_background_color = c)
except Exception, e:
print e.read()
print "Update profile:"
import time
api.profile(description = time.time())
raw_input()
if favorites:
print "Favorites:"
print "Create:"
api.favorite_create(6861002055)
print "Favorites:"
for f in api.favorites():
print "%s %s" % (f["user"]["screen_name"], f["text"])
raw_input()
print "Destroy:"
api.favorite_destroy(6861002055)
raw_input()
if block:
print "Blocks:"
print "Blocking Users:"
for u in api.block_list():
print u["screen_name"]