diff --git a/config.json b/config.json index dcd3bcf..cfe554a 100644 --- a/config.json +++ b/config.json @@ -25,10 +25,10 @@ "notarize" ], "cookies": [ - "api.x.com" + "https://api.x.com/1.1/account/settings.json" ], "headers": [ - "api.x.com" + "https://api.x.com/1.1/account/settings.json" ], "requests": [ { diff --git a/src/index.ts b/src/index.ts index b36e857..c26db27 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,34 +40,38 @@ export function start() { * Note that the url needs to be specified in the `config` too, otherwise the request will be refused. */ export function two() { - const cookies = getCookiesByHost('api.x.com'); - const headers = getHeadersByHost('api.x.com'); + const cookies = getCookiesByHost('https://api.x.com/1.1/account/settings.json'); + const headers = getHeadersByHost('https://api.x.com/1.1/account/settings.json'); if ( !cookies.auth_token || !cookies.ct0 || !headers['x-csrf-token'] || - !headers['authorization'] + !headers['authorization'] || + !headers['x-client-transaction-id'] ) { outputJSON(false); return; } + const cookieString = Object.entries(cookies).map(([name, value]) => `${name}=${value}`).join('; ') + outputJSON({ url: 'https://api.x.com/1.1/account/settings.json', method: 'GET', headers: { - 'x-twitter-client-language': 'en', + Cookie: cookieString, 'x-csrf-token': headers['x-csrf-token'], + 'x-client-transaction-id': headers['x-client-transaction-id'], Host: 'api.x.com', authorization: headers.authorization, - Cookie: `lang=en; auth_token=${cookies.auth_token}; ct0=${cookies.ct0}`, 'Accept-Encoding': 'identity', Connection: 'close', }, secretHeaders: [ `x-csrf-token: ${headers['x-csrf-token']}`, - `cookie: lang=en; auth_token=${cookies.auth_token}; ct0=${cookies.ct0}`, + `x-client-transaction-id: ${headers['x-client-transaction-id']}`, + `cookie: ${cookieString}`, `authorization: ${headers.authorization}`, ], });