Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zmovane/rex

Reverse Engineered Twitter's API
https://github.com/zmovane/rex

reverse-engineering scraper twitter twitter-api twitter-api-v2 twitter-scraper twitterscraper

Last synced: about 2 months ago
JSON representation

Reverse Engineered Twitter's API

Awesome Lists containing this project

README

        

# reX

[![go report card](https://goreportcard.com/badge/github.com/amovane/reX "go report card")](https://goreportcard.com/report/github.com/amovane/reX)
[![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)



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

```golang
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

```golang
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

```golang
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

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