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

質問編集履歴

2

別サイトで行った同じ内容の質問のリンクを追加

2024/03/24 04:55

投稿

ssmn_dev
ssmn_dev

スコア1

title CHANGED
File without changes
body CHANGED
@@ -164,4 +164,8 @@
164
164
  前に行った質問(APIの設定等)
165
165
  https://teratail.com/questions/dqc61u6a7o1huq
166
166
  https://qiita.com/ssmn93/questions/1c08e39769cb499d85a5
167
- https://ja.stackoverflow.com/questions/98939/twitter-api%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bapiresponseerror-request-failed-with-code-401%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%ae%e8%a7%a3%e6%b6%88/98941#98941
167
+ https://ja.stackoverflow.com/questions/98939/twitter-api%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bapiresponseerror-request-failed-with-code-401%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%ae%e8%a7%a3%e6%b6%88/98941#98941
168
+
169
+ 別サイトでの質問
170
+ https://qiita.com/ssmn93/questions/8488a912e8b88a4b1e00
171
+ https://ja.stackoverflow.com/questions/98944/apiresponseerror-request-failed-with-code-403%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%ae%e8%a7%a3%e6%b6%88

1

他サイトでの質問リンクを追加

2024/03/24 04:48

投稿

ssmn_dev
ssmn_dev

スコア1

title CHANGED
File without changes
body CHANGED
@@ -106,7 +106,7 @@
106
106
 
107
107
  async function getTweetsWithHashtag(hashtag) {
108
108
  try {
109
- const tweets = await appOnlyClient.get(`https://api.twitter.com/2/tweets/search/recent?query=%23カフェインはいいぞ委員会&max_results=10`);
109
+ const tweets = await appOnlyClient.get(`https://api.twitter.com/2/tweets/search/recent?query=%23(タグ名)&max_results=10`);
110
110
  console.log('Tweets:', tweets.data);
111
111
  return tweets.data; // Twitter APIからのレスポンスを返す
112
112
  } catch (error) {
@@ -117,12 +117,12 @@
117
117
 
118
118
  module.exports = {
119
119
  data: new SlashCommandBuilder()
120
- .setName('caffeine')
120
+ .setName('search')
121
- .setDescription('#カフェンはいいぞ委員会'),
121
+ .setDescription('ート取得'),
122
122
 
123
123
  async execute(interaction) {
124
124
  try {
125
- const tweets = await getTweetsWithHashtag('#カフェインはいいぞ委員会');
125
+ const tweets = await getTweetsWithHashtag('#(タグ名)');
126
126
  console.log(tweets);
127
127
 
128
128
  if (tweets.length > 0) {
@@ -161,4 +161,7 @@
161
161
  もともとteratail等で「ApiResponseError: Request failed with code 401」エラーが発生したため質問し、いただいた回答を元に自分なりに変更したところ403エラーが発生しました。
162
162
 
163
163
  ### 補足
164
- [前に行った質問(APIの設定等)](https://teratail.com/questions/dqc61u6a7o1huq)
164
+ 前に行った質問(APIの設定等)
165
+ https://teratail.com/questions/dqc61u6a7o1huq
166
+ https://qiita.com/ssmn93/questions/1c08e39769cb499d85a5
167
+ https://ja.stackoverflow.com/questions/98939/twitter-api%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bapiresponseerror-request-failed-with-code-401%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%ae%e8%a7%a3%e6%b6%88/98941#98941