Skip to content

Latest commit

 

History

History
72 lines (59 loc) · 1.73 KB

README.md

File metadata and controls

72 lines (59 loc) · 1.73 KB

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.

Installation

go get -u github.com/amovane/reX

Login

uname := os.Getenv("USER_NAME")
upwd := os.Getenv("PASSWORD")
x := reX.New()
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(uname, upwd)
    x.SaveCookies(cookiesPath)
}

Followings

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

Followers

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

Is following

uid, _ := x.GetUserIDByScreenName("jarredsumner")
uidOfFollower, _ := x.GetUserIDByScreenName("cybermageek")
isFollowing := x.IsFollowing(uid, uidOfFollower)