/reX

Reverse Engineered Twitter's API

Primary LanguageGo

reX

go report card MIT license

Since twitter dev removed the API for accessing user followers and following, developers have found it difficult to obtain this data. Here, I'm sharing my reverse engineering solution. If it's helpful to you, please let me know.

Login

uname := os.Getenv("USER_NAME")
upwd := os.Getenv("PASSWORD")
x := reX.New(uname, upwd)
wd, _ := os.Getwd()
cookiesPath := fmt.Sprintf("%s/cookies.json", wd)
err := x.SetCookies(cookiesPath)
if err != nil || !x.IsLoggedIn() {
    println("You must login first")
    x.Login()
    x.SaveCookies(cookiesPath)
}

Followings

var cursor *string
var tweets []reX.Legacy
for {
    tweets, cursor, err = x.GetFollowingsByScreenName("shareverse_", cursor)
    for _, tweet := range tweets {
        println(tweet.ScreenName)
    }
    if cursor == nil || err != nil {
        break
    }
}

Followers

var cursor *string
var tweets []reX.Legacy
for {
    tweets, cursor, err = x.GetFollowersByScreenName("shareverse_", cursor)
    for _, tweet := range tweets {
        println(tweet.ScreenName)
    }
    if cursor == nil || err != nil {
        break
    }
}