Skip to content

Commit dc5cadf

Browse files
authored
Add missing token to api calls to Twitter's CDN (#128)
* Added changeset * Added token * Added changeset * Updated changeset
1 parent 5637b66 commit dc5cadf

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.changeset/honest-rabbits-swim.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-tweet': patch
3+
---
4+
5+
Added missing token to API requests to Twitter's CDN

packages/react-tweet/src/api/get-tweet.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ export class TwitterApiError extends Error {
2424

2525
const TWEET_ID = /^[0-9]+$/
2626

27+
function getToken(id: string) {
28+
return ((Number(id) / 1e15) * Math.PI)
29+
.toString(6 ** 2)
30+
.replace(/(0+|\.)/g, '')
31+
}
32+
2733
/**
2834
* Fetches a tweet from the Twitter syndication API.
2935
*/
@@ -46,16 +52,20 @@ export async function getTweet(
4652
'tfw_follower_count_sunset:true',
4753
'tfw_tweet_edit_backend:on',
4854
'tfw_refsrc_session:on',
55+
'tfw_fosnr_soft_interventions_enabled:on',
56+
'tfw_show_birdwatch_pivots_enabled:on',
4957
'tfw_show_business_verified_badge:on',
5058
'tfw_duplicate_scribes_to_settings:on',
59+
'tfw_use_profile_image_shape_enabled:on',
5160
'tfw_show_blue_verified_badge:on',
5261
'tfw_legacy_timeline_sunset:true',
5362
'tfw_show_gov_verified_badge:on',
5463
'tfw_show_business_affiliate_badge:on',
5564
'tfw_tweet_edit_frontend:on',
5665
].join(';')
5766
)
58-
67+
url.searchParams.set('token', getToken(id))
68+
5969
const res = await fetch(url.toString(), fetchOptions)
6070
const isJson = res.headers.get('content-type')?.includes('application/json')
6171
const data = isJson ? await res.json() : undefined

0 commit comments

Comments
 (0)