nodejs twitter api 通过多个 public 帐户或 screen_names 获取推文
nodejs twitter api get tweets by multiple public account or screen_names
我正在尝试通过多个 public 帐户获取推文,比如 @TwitterDev
和 @tolga_tezel
。
为此目的使用 node.js 和 twit
包。
T = new Twit({
consumer_key: TWITTER_CONSUMER_KEY,
consumer_secret: TWITTER_CONSUMER_SECRET,
access_token: TWITTER_ACCESS_TOKEN,
access_token_secret: TWITTER_ACCESS_TOKEN_SECRET,
});
getTweets = async (request:Request, reponse:Response)=>{
//const {keyword} = request.params;
const data = await this.T.get('statuses/user_timeline', { screen_name:'twitterdev', count: 10 });
reponse.send(data);
}
类似于:
const data = await this.T.get('statuses/user_timeline', { screen_name:'twitterdev', screen_name:'tolga_tezel', count: 10 });
怎么办?可以在单个 api 调用中完成吗?
不可能在单个 API 调用中完成此操作。 statuses/user_timeline
API 仅使用一个用户名 (screen_name) 作为参数(参见 Twitter documentation)。为此,您需要多次调用 user_timeline API,每次都使用一个单独的用户名。
我正在尝试通过多个 public 帐户获取推文,比如 @TwitterDev
和 @tolga_tezel
。
为此目的使用 node.js 和 twit
包。
T = new Twit({
consumer_key: TWITTER_CONSUMER_KEY,
consumer_secret: TWITTER_CONSUMER_SECRET,
access_token: TWITTER_ACCESS_TOKEN,
access_token_secret: TWITTER_ACCESS_TOKEN_SECRET,
});
getTweets = async (request:Request, reponse:Response)=>{
//const {keyword} = request.params;
const data = await this.T.get('statuses/user_timeline', { screen_name:'twitterdev', count: 10 });
reponse.send(data);
}
类似于:
const data = await this.T.get('statuses/user_timeline', { screen_name:'twitterdev', screen_name:'tolga_tezel', count: 10 });
怎么办?可以在单个 api 调用中完成吗?
不可能在单个 API 调用中完成此操作。 statuses/user_timeline
API 仅使用一个用户名 (screen_name) 作为参数(参见 Twitter documentation)。为此,您需要多次调用 user_timeline API,每次都使用一个单独的用户名。