refactor: switch to twitter-api-v2 from twit (#9652)
This commit is contained in:
@@ -2,14 +2,14 @@ const utils = require('../utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const keyword = ctx.params.keyword;
|
||||
const limit = ctx.params.limit || 50;
|
||||
const result = await utils.getTwit().get('search/tweets', {
|
||||
const limit = ctx.params.limit ?? 50;
|
||||
const client = await utils.getAppClient();
|
||||
const data = await client.v1.get('search/tweets.json', {
|
||||
q: keyword,
|
||||
count: limit,
|
||||
tweet_mode: 'extended',
|
||||
result_type: 'recent',
|
||||
});
|
||||
const data = result.data;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Twitter Keyword - ${keyword}`,
|
||||
|
||||
@@ -5,14 +5,14 @@ module.exports = async (ctx) => {
|
||||
|
||||
// For compatibility
|
||||
const { exclude_replies, include_rts, count } = utils.parseRouteParams(ctx.params.routeParams);
|
||||
const result = await utils.getTwit().get('statuses/user_timeline', {
|
||||
const client = await utils.getAppClient();
|
||||
const data = await client.v1.get('statuses/user_timeline.json', {
|
||||
screen_name: id,
|
||||
tweet_mode: 'extended',
|
||||
exclude_replies,
|
||||
include_rts,
|
||||
count,
|
||||
});
|
||||
const data = result.data;
|
||||
const userInfo = data[0].user;
|
||||
|
||||
const profileImageUrl = userInfo.profile_image_url || userInfo.profile_image_url_https;
|
||||
|
||||
Reference in New Issue
Block a user