-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: twitter api base on public token (#10782)
* refactor: twitter api base on public token * refactor: code style * refactor: code style * refactor: lock file
- Loading branch information
1 parent
b7bbb9e
commit 7d76620
Showing
10 changed files
with
142 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import urlcat from 'urlcat' | ||
import { getHeaders } from './getTokens.js' | ||
import type { TwitterBaseAPI } from '../../entry-types.js' | ||
import { fetchJSON } from '../../helpers/fetchJSON.js' | ||
import type { TwitterBaseAPI } from '../../entry-types.js' | ||
|
||
export async function getSettings() { | ||
return fetchJSON<TwitterBaseAPI.Settings>( | ||
urlcat('https://twitter.com/i/api/1.1/account/settings.json', { | ||
include_mention_filter: false, | ||
include_nsfw_user_flag: false, | ||
include_nsfw_admin_flag: false, | ||
include_ranked_timeline: false, | ||
include_alt_text_compose: false, | ||
include_country_code: false, | ||
include_ext_dm_nsfw_media_filter: false, | ||
return fetchJSON<TwitterBaseAPI.Settings>('https://api.twitter.com/1.1/account/settings.json', { | ||
headers: await getHeaders({ | ||
referer: 'https://twitter.com/home', | ||
}), | ||
{ | ||
headers: await getHeaders({ | ||
referer: 'https://twitter.com/home', | ||
}), | ||
}, | ||
) | ||
credentials: 'include', | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 3 additions & 8 deletions
11
packages/web3-providers/src/Twitter/apis/getUserNFTContainer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,26 @@ | ||
import urlcat from 'urlcat' | ||
import { getTokens, getHeaders } from './getTokens.js' | ||
import { getHeaders } from './getTokens.js' | ||
import { fetchJSON } from '../../helpers/fetchJSON.js' | ||
import type { TwitterBaseAPI } from '../../entry-types.js' | ||
|
||
export async function getUserNFTContainer(screenName: string) { | ||
const { queryToken } = await getTokens() | ||
|
||
return fetchJSON<{ | ||
data: { | ||
user: { | ||
result: TwitterBaseAPI.NFTContainer | ||
} | ||
} | ||
}>( | ||
urlcat('https://twitter.com/i/api/graphql/:queryToken/userNftContainer_Query', { | ||
queryToken, | ||
urlcat('https://twitter.com/i/api/graphql/z-_uxIiYELU35OzocPdDIw/userNftContainer_Query', { | ||
variables: JSON.stringify({ | ||
screenName, | ||
}), | ||
features: JSON.stringify({ | ||
responsive_web_twitter_blue_verified_badge_is_enabled: false, | ||
}), | ||
}), | ||
{ | ||
headers: await getHeaders({ | ||
referer: `https://twitter.com/${screenName}/nft`, | ||
}), | ||
credentials: 'include', | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.