Skip to content

Commit

Permalink
feat: update twitter api path
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Sep 15, 2024
1 parent b63a362 commit cbfd29d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
27 changes: 14 additions & 13 deletions lib/routes/twitter/api/web-api/constants.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
const baseUrl = 'https://x.com/i/api';

const graphQLEndpointsPlain = [
'/graphql/eS7LO5Jy3xgmd3dbL044EA/UserTweets',
'/graphql/k5XapwcSikNsEsILW5FvgA/UserByScreenName',
'/graphql/k3YiLNE_MAy5J-NANLERdg/HomeTimeline',
'/graphql/E3opETHurmVJflFsUBVuUQ/UserTweets',
'/graphql/Yka-W8dz7RaEuQNkroPkYw/UserByScreenName',
'/graphql/HJFjzBgCs16TqxewQOeLNg/HomeTimeline',
'/graphql/DiTkXJgLqBBxCs7zaYsbtA/HomeLatestTimeline',
'/graphql/3GeIaLmNhTm1YsUmxR57tg/UserTweetsAndReplies',
'/graphql/TOU4gQw8wXIqpSzA4TYKgg/UserMedia',
'/graphql/B8I_QCljDBVfin21TTWMqA/Likes',
'/graphql/bt4TKuFz4T7Ckk-VvQVSow/UserTweetsAndReplies',
'/graphql/dexO_2tohK86JDudXXG3Yw/UserMedia',
'/graphql/tD8zKvQzwY3kdx5yz6YmOw/UserByRestId',
'/graphql/flaR-PUMshxFWZWPNpq4zA/SearchTimeline',
'/graphql/UN1i3zUiCWa-6r-Uaho4fw/SearchTimeline',
'/graphql/TOTgqavWmxywKv5IbMMK1w/ListLatestTweetsTimeline',
'/graphql/zJvfJs3gSbrVhC0MKjt_OQ/TweetDetail',
'/graphql/QuBlQ6SxNAQCt6-kBiCXCQ/TweetDetail',
];

const gqlMap = Object.fromEntries(graphQLEndpointsPlain.map((endpoint) => [endpoint.split('/')[3].replace(/V2$|Query$|QueryV2$/, ''), endpoint]));

const gqlFeatureUser = {
hidden_profile_likes_enabled: true,
hidden_profile_subscriptions_enabled: true,
rweb_tipjar_consumption_enabled: true,
responsive_web_graphql_exclude_directive_enabled: true,
verified_phone_label_enabled: false,
subscriptions_verification_info_is_identity_verified_enabled: true,
subscriptions_verification_info_verified_since_enabled: true,
highlights_tweets_tab_ui_enabled: true,
responsive_web_twitter_article_notes_tab_enabled: true,
subscriptions_feature_can_gift_premium: true,
creator_subscriptions_tweet_preview_api_enabled: true,
responsive_web_graphql_skip_user_profile_image_extensions_enabled: false,
responsive_web_graphql_timeline_navigation_enabled: true,
};
const gqlFeatureFeed = {
rweb_tipjar_consumption_enabled: true,
responsive_web_graphql_exclude_directive_enabled: true,
verified_phone_label_enabled: false,
creator_subscriptions_tweet_preview_api_enabled: true,
responsive_web_graphql_timeline_navigation_enabled: true,
responsive_web_graphql_skip_user_profile_image_extensions_enabled: false,
communities_web_enable_tweet_community_results_fetch: true,
c9s_tweet_anatomy_moderator_badge_enabled: true,
tweetypie_unmention_optimization_enabled: true,
articles_preview_enabled: true,
responsive_web_edit_tweet_api_enabled: true,
graphql_is_translatable_rweb_tweet_is_translatable_enabled: true,
view_counts_everywhere_api_enabled: true,
longform_notetweets_consumption_enabled: true,
responsive_web_twitter_article_tweet_consumption_enabled: true,
tweet_awards_web_tipping_enabled: false,
creator_subscriptions_quote_tweet_preview_enabled: false,
freedom_of_speech_not_reach_fetch_enabled: true,
standardized_nudges_misinfo: true,
tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled: true,
Expand All @@ -61,8 +64,7 @@ const TweetDetailFeatures = {
responsive_web_graphql_skip_user_profile_image_extensions_enabled: false,
communities_web_enable_tweet_community_results_fetch: true,
c9s_tweet_anatomy_moderator_badge_enabled: true,
articles_preview_enabled: false,
tweetypie_unmention_optimization_enabled: true,
articles_preview_enabled: true,
responsive_web_edit_tweet_api_enabled: true,
graphql_is_translatable_rweb_tweet_is_translatable_enabled: true,
view_counts_everywhere_api_enabled: true,
Expand All @@ -73,7 +75,6 @@ const TweetDetailFeatures = {
freedom_of_speech_not_reach_fetch_enabled: true,
standardized_nudges_misinfo: true,
tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled: true,
tweet_with_visibility_results_prefer_gql_media_interstitial_enabled: true,
rweb_video_timestamps_enabled: true,
longform_notetweets_rich_text_read_enabled: true,
longform_notetweets_inline_media_enabled: true,
Expand Down
3 changes: 1 addition & 2 deletions lib/routes/twitter/api/web-api/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ConfigNotFoundError from '@/errors/types/config-not-found';
import { baseUrl, gqlFeatures, bearerToken, gqlMap } from './constants';
import { config } from '@/config';
import got from '@/utils/got';
import queryString from 'query-string';
import { Cookie, CookieJar } from 'tough-cookie';
import { CookieAgent, CookieClient } from 'http-cookie-agent/undici';
Expand All @@ -26,7 +25,7 @@ const token2Cookie = (token) =>
uri: proxy.proxyUri,
})
: new CookieAgent({ cookies: { jar } });
await got('https://x.com', {
await ofetch('https://x.com', {
dispatcher: agent,
});
return JSON.stringify(jar.serializeSync());
Expand Down

0 comments on commit cbfd29d

Please sign in to comment.