質問編集履歴
1
誤字
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Twitter
|
1
|
+
Twitter API利用時に400エラーが出てしまう
|
test
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
### 前提
|
2
2
|
|
3
3
|
Twitterの自分がいいねしたツイートをNotionへ保存したく、
|
4
|
-
下記コードをダウンロードしてみたのですが40
|
4
|
+
下記コードをダウンロードしてみたのですが400エラーが出てしまいます
|
5
5
|
https://github.com/yukinakai/fav_tweet_to_notion
|
6
6
|
|
7
7
|
|
@@ -14,18 +14,11 @@
|
|
14
14
|
### 発生している問題・エラーメッセージ
|
15
15
|
|
16
16
|
```
|
17
|
-
2022-07-1
|
18
|
-
|
19
|
-
File "/Users/xxxxx/Downloads/fav_tweet_to_notion-main/main.py", line 37, in <module>
|
20
|
-
main()
|
21
|
-
File "/Users/xxxxx/Downloads/fav_tweet_to_notion-main/main.py", line 8, in main
|
22
|
-
tweets_in_notion = notion.get_tweets_in_notion()
|
23
|
-
File "/Users/xxxxx/Downloads/fav_tweet_to_notion-main/notion.py", line 64, in get_tweets_in_notion
|
24
|
-
json_response = connect_to_endpoint(url, headers, payload)
|
25
|
-
File "/Users/xxxxx/Downloads/fav_tweet_to_notion-main/notion.py", line 50, in connect_to_endpoint
|
26
|
-
raise Exception(
|
27
|
-
Exception: Request returned an error: 401 {"object":"error","status":401,"code":"unauthorized","message":"API token is invalid."}
|
17
|
+
2022-07-14 22:08:02,165:INFO:main.py:9:{'status': 'success', 'action': 'get tweets in notion'}
|
18
|
+
2022-07-14 22:08:02,388:ERROR:twitter.py:26:{'action': 'post notion endpoint', 'statud_code': 400, 'message': '{"errors":[{"parameters":{"id":["xxxx"]},"message":"The `id` query parameter value [xxxx] is not valid"}],"title":"Invalid Request","detail":"One or more parameters to your request was invalid.","type":"https://api.twitter.com/2/problems/invalid-request"}', 'data': {'max_results': 100, 'expansions': 'attachments.media_keys,author_id,referenced_tweets.id,referenced_tweets.id.author_id', 'tweet.fields': 'attachments,author_id,created_at,id,text,referenced_tweets', 'user.fields': 'name,username,profile_image_url', 'media.fields': 'url'}}
|
28
19
|
```
|
20
|
+
|
21
|
+
xxxxは自分のTwitter ID名が入っています。
|
29
22
|
|
30
23
|
### 該当のソースコード
|
31
24
|
|
@@ -34,11 +27,10 @@
|
|
34
27
|
### 試したこと
|
35
28
|
|
36
29
|
- python-dotenv、requests、requests-oauthlibはインストール済みです
|
37
|
-
- 各種APIコード等は
|
30
|
+
- 各種APIコード等は環境変数で自分の発行したものに変更しています。
|
38
|
-
- Twitter APIはStandalone AppsではなくElevatedにしています(
|
31
|
+
- Twitter APIはStandalone AppsではなくElevatedにしています(エラーの原因になることがあるという記事を読んだため)
|
39
32
|
- Notionは作者の[デモページ](https://www.notion.so/d0028b55bdb84be4aba8bbb4514f19b7?v=e22090af5a6647f7b2bec9b23f6840e1)を自分のNotionにコピーし、データベースIDもそのコピーしたページのものを指定しました
|
40
33
|
|
41
34
|
### 補足情報(FW/ツールのバージョンなど)
|
35
|
+
Python3.8.12
|
42
36
|
|
43
|
-
環境はvisual studio codeを使用しています
|
44
|
-
Pythonは3.8.12です
|