Skip to content

Instantly share code, notes, and snippets.

@tmcw tmcw/delete_all.go Secret
Created Jun 5, 2017

Embed
What would you like to do?
package main
import (
"encoding/csv"
"fmt"
"github.com/ChimeraCoder/anaconda"
"io"
"log"
"strconv"
// "strings"
// "net/url"
"os"
)
// Main for tweets up to the limit
// func main() {
// anaconda.SetConsumerKey("")
// anaconda.SetConsumerSecret("")
// api := anaconda.NewTwitterApi("", "")
// var deleted int64 = 0
//
// for {
// params := url.Values{
// "screen_name": []string{"tmcw"},
// "count": []string{"1000"},
// "max_id": []string{"632284973349769216"},
// }
//
// tweets, err := api.GetUserTimeline(params)
//
// fmt.Println(tweets)
//
// if len(tweets) == 0 {
// break
// }
//
// if err != nil {
// log.Fatal(err)
// }
//
// for i := 0; i < len(tweets); i++ {
// go api.DeleteTweet(tweets[i].Id, true)
// deleted++
// if deleted%100 == 0 {
// fmt.Println("Deleted ", deleted)
// }
// }
// }
// }
func main() {
anaconda.SetConsumerKey("")
anaconda.SetConsumerSecret("")
api := anaconda.NewTwitterApi("", "")
var deleted int64 = 0
tweets_csv, err := os.Open("/Users/tmcw/Downloads/1458271_3a607ccffa9088feecc17ae57bb619277b8beb90/tweets.csv")
if err != nil {
log.Fatal(err)
}
r := csv.NewReader(tweets_csv)
r.Read()
var start_id int64 = 494491108223619072
started := false
for {
record, err := r.Read()
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
i, err := strconv.ParseInt(record[0], 10, 64)
if err != nil {
panic(err)
}
if i == start_id {
started = true
fmt.Println("started")
}
if started {
_, err = api.DeleteTweet(i, true)
if err != nil {
}
deleted++
if deleted%100 == 0 {
fmt.Println("Deleted ", deleted)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.