@@ -10,6 +10,7 @@ import logger from '@/utils/logger';
1010import ofetch from '@/utils/ofetch' ;
1111import proxy from '@/utils/proxy' ;
1212
13+ import { getClientTransactionId } from './client-transaction' ;
1314import { baseUrl , bearerToken , gqlFeatures , gqlMap , thirdPartySupportedAPI } from './constants' ;
1415import login from './login' ;
1516
@@ -80,6 +81,7 @@ export const twitterGot = async (
8081 params ,
8182 options ?: {
8283 allowNoAuth ?: boolean ;
84+ headers ?: Record < string , string > ;
8385 }
8486) => {
8587 const auth = await getAuth ( 30 ) ;
@@ -171,6 +173,7 @@ export const twitterGot = async (
171173 : {
172174 'x-guest-token' : jsonCookie . gt ,
173175 } ) ,
176+ ...options ?. headers ,
174177 } ,
175178 dispatcher : dispatchers ?. agent ,
176179 } ) ;
@@ -263,7 +266,14 @@ export const paginationTweets = async (endpoint: string, userId: number | undefi
263266 } ) ;
264267 return data ;
265268 }
266- const { data } = await twitterGot ( baseUrl + gqlMap [ endpoint ] , params ) ;
269+ const transactionId = endpoint === 'UserTweetsAndReplies' ? await getClientTransactionId ( 'GET' , new URL ( baseUrl + gqlMap [ endpoint ] ) . pathname ) : undefined ;
270+ const { data } = await twitterGot ( baseUrl + gqlMap [ endpoint ] , params , {
271+ headers : transactionId
272+ ? {
273+ 'x-client-transaction-id' : transactionId ,
274+ }
275+ : undefined ,
276+ } ) ;
267277 return data ;
268278 } ;
269279
0 commit comments