Skip to content

Instantly share code, notes, and snippets.

@tajuszk
Last active December 3, 2020 06:25
Show Gist options
  • Save tajuszk/287d430605e7ee93a61e883434adb7fa to your computer and use it in GitHub Desktop.
Save tajuszk/287d430605e7ee93a61e883434adb7fa to your computer and use it in GitHub Desktop.
// ツイートしたい文章
const message = 'ほげほげ';
// ブラウザから必要な情報を探してコピペする
const authToken = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const ct0 = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const bearerToken = 'Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
// ここ以降は変更不要
function main() {
const url = 'https://twitter.com/i/api/1.1/statuses/update.json';
const options = {
status: message,
}
const cookie = {
'auth_token' : authToken,
'ct0' : ct0
}
let cookieStr = '';
for (let i in cookie) {
cookieStr += i + '=' + cookie[i] + '; ';
}
const headers = {
'Authorization' : bearerToken,
'Cookie': cookieStr,
'x-csrf-token': ct0,
}
const params = {
method: 'POST',
contentType: 'application/x-www-form-urlencoded',
payload: options,
headers: headers,
muteHttpExceptions: true,
}
const response = UrlFetchApp.fetch(url, params);
const responseHeaders = response.getHeaders();
const responseCookie = response.getAllHeaders()['Set-Cookie'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment