teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

fix parameter

2019/02/20 09:27

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -57,4 +57,40 @@
57
57
  また、Classの使い方が間違っている等ありましたら、
58
58
  そちらもご指摘頂ければ幸いです。
59
59
 
60
- 長々と失礼致しました。
60
+ 長々と失礼致しました。
61
+
62
+ 追記:
63
+ can110様
64
+ ご返信、ご回答頂きました方々、ありがとうございました。
65
+ ご回答、ご指摘頂きましたとおり、変更したコードを下記に示します。
66
+
67
+ ```python
68
+ from requests_oauthlib import OAuth1Session
69
+
70
+ USER_TL = "https://api.twitter.com/1.1/statuses/user_timeline.json"
71
+ API_KEY = "*"
72
+ API_SECRET_KEY = "*"
73
+ ACCESS_TOKEN = "*"
74
+ ACCESS_TOKEN_SECRET = "*"
75
+
76
+ class Twitterclass:
77
+ def __init__(self,key,secret_key,token,secret_token):
78
+ self.twitter = OAuth1Session(key, secret_key, token, secret_token)
79
+ self.param = {
80
+ "screen_name": "apple",
81
+ "count": 200,
82
+ "include_entities": True,
83
+ "exclude_replies": False,
84
+ "include_rts": False,
85
+ }
86
+
87
+ def get_user_timeline(self):
88
+ return self.twitter.get(url = USER_TL,params = self.param)
89
+ # Twitterclass END
90
+
91
+ twitter = Twitterclass(API_KEY,
92
+ API_SECRET_KEY,
93
+ ACCESS_TOKEN,
94
+ ACCESS_TOKEN_SECRET)
95
+ user_timeline = twitter.get_user_timeline()
96
+ ```

2

add import code

2019/02/20 09:27

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -3,6 +3,8 @@
3
3
  納得のいかないエラーが出て困っています。
4
4
  下記ソースコードです。
5
5
  ```python
6
+ from requests_oauthlib import OAuth1Session
7
+
6
8
  USER_TL = "https://api.twitter.com/1.1/statuses/user_timeline.json"
7
9
  API_KEY = "*"
8
10
  API_SECRET_KEY = "*"

1

脱字がありました。

2019/02/20 08:10

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -4,6 +4,11 @@
4
4
  下記ソースコードです。
5
5
  ```python
6
6
  USER_TL = "https://api.twitter.com/1.1/statuses/user_timeline.json"
7
+ API_KEY = "*"
8
+ API_SECRET_KEY = "*"
9
+ ACCESS_TOKEN = "*"
10
+ ACCESS_TOKEN_SECRET = "*"
11
+
7
12
  class Twitterclass:
8
13
  def __init__(self,key,secret_key,token,secret_token):
9
14
  self.twitter = OAuth1Session(key, secret_key, token, secret_token)