質問編集履歴
3
fix parameter
test
CHANGED
File without changes
|
test
CHANGED
@@ -117,3 +117,75 @@
|
|
117
117
|
|
118
118
|
|
119
119
|
長々と失礼致しました。
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
追記:
|
124
|
+
|
125
|
+
can110様
|
126
|
+
|
127
|
+
ご返信、ご回答頂きました方々、ありがとうございました。
|
128
|
+
|
129
|
+
ご回答、ご指摘頂きましたとおり、変更したコードを下記に示します。
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
```python
|
134
|
+
|
135
|
+
from requests_oauthlib import OAuth1Session
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
USER_TL = "https://api.twitter.com/1.1/statuses/user_timeline.json"
|
140
|
+
|
141
|
+
API_KEY = "*"
|
142
|
+
|
143
|
+
API_SECRET_KEY = "*"
|
144
|
+
|
145
|
+
ACCESS_TOKEN = "*"
|
146
|
+
|
147
|
+
ACCESS_TOKEN_SECRET = "*"
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
class Twitterclass:
|
152
|
+
|
153
|
+
def __init__(self,key,secret_key,token,secret_token):
|
154
|
+
|
155
|
+
self.twitter = OAuth1Session(key, secret_key, token, secret_token)
|
156
|
+
|
157
|
+
self.param = {
|
158
|
+
|
159
|
+
"screen_name": "apple",
|
160
|
+
|
161
|
+
"count": 200,
|
162
|
+
|
163
|
+
"include_entities": True,
|
164
|
+
|
165
|
+
"exclude_replies": False,
|
166
|
+
|
167
|
+
"include_rts": False,
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
def get_user_timeline(self):
|
174
|
+
|
175
|
+
return self.twitter.get(url = USER_TL,params = self.param)
|
176
|
+
|
177
|
+
# Twitterclass END
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
twitter = Twitterclass(API_KEY,
|
182
|
+
|
183
|
+
API_SECRET_KEY,
|
184
|
+
|
185
|
+
ACCESS_TOKEN,
|
186
|
+
|
187
|
+
ACCESS_TOKEN_SECRET)
|
188
|
+
|
189
|
+
user_timeline = twitter.get_user_timeline()
|
190
|
+
|
191
|
+
```
|
2
add import code
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,6 +7,10 @@
|
|
7
7
|
下記ソースコードです。
|
8
8
|
|
9
9
|
```python
|
10
|
+
|
11
|
+
from requests_oauthlib import OAuth1Session
|
12
|
+
|
13
|
+
|
10
14
|
|
11
15
|
USER_TL = "https://api.twitter.com/1.1/statuses/user_timeline.json"
|
12
16
|
|
1
脱字がありました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,6 +9,16 @@
|
|
9
9
|
```python
|
10
10
|
|
11
11
|
USER_TL = "https://api.twitter.com/1.1/statuses/user_timeline.json"
|
12
|
+
|
13
|
+
API_KEY = "*"
|
14
|
+
|
15
|
+
API_SECRET_KEY = "*"
|
16
|
+
|
17
|
+
ACCESS_TOKEN = "*"
|
18
|
+
|
19
|
+
ACCESS_TOKEN_SECRET = "*"
|
20
|
+
|
21
|
+
|
12
22
|
|
13
23
|
class Twitterclass:
|
14
24
|
|