fix: twitter plugin

This commit is contained in:
tsukino
2024-12-11 17:03:58 +08:00
parent 1c18826b1f
commit cbdf87e289
2 changed files with 12 additions and 8 deletions

View File

@@ -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": [
{

View File

@@ -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}`,
],
});