Skip to content

Instantly share code, notes, and snippets.

@wwwmarcos
Created September 14, 2021 16:29
Show Gist options
  • Save wwwmarcos/9e56f890198467bc93dc99e372367482 to your computer and use it in GitHub Desktop.
Save wwwmarcos/9e56f890198467bc93dc99e372367482 to your computer and use it in GitHub Desktop.
const Twitter = require('twitter-lite')
const twitter = new Twitter({
consumer_key: process.env.CONSUMER_KEY,
consumer_secret: process.env.CONSUMER_SECRET,
access_token_key: process.env.ACCESS_TOKEN_KEY,
access_token_secret: process.env.ACCESS_TOKEN_SECRET
})
const SOURCE_USER = process.env.SOURCE_USER
const start = async () => {
const data = await twitter.get('friends/list', {
screen_name: SOURCE_USER,
count: 200,
skip_status: true,
include_user_entities: false
})
for (const user of data.users) {
try {
const result = await twitter.post('friendships/destroy', {
screen_name: user.screen_name
})
console.log(result.name)
} catch (error) {
console.log(error.errors)
}
}
}
start().catch(console.error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment