go-graphtweets

module
v0.0.0-...-c691ec9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2021 License: MIT

README

Go Report Card

go-graphtweets

Build Twitter networks.

go-graphtweets is the sister of the graphTweets R package.

Install

Install go-twitter

go get github.com/dghubble/go-twitter/twitter

Install go-graphtweets

go get github.com/JohnCoene/go-graphtweets/graphtweets

Documentation

The documentation is on godoc

Example

Set up go-twitter session.

// get tweets with go-twitter
config := oauth1.NewConfig("consumerKey", "consumerSecret")
token := oauth1.NewToken("accessToken", "accessSecret")
httpClient := config.Client(oauth1.NoContext, token)

// Twitter client
client := twitter.NewClient(httpClient)

// Search Tweets
search, _, _ := client.Search.Tweets(&twitter.SearchTweetParams{
  Query: "#golang",
})

Build graphs.

mentionsGraph := graphtweets.GetMentionsGraph(*search) // build mentions graph
retweetGraph := graphtweets.GetRetweetGraph(*search) // build retweet graph
hashtagGraph := graphtweets.GetHashtagGraph(*search) // build hashtag graph

Convert either graphs to wide.

wide := graphtweets.ToWide(&mentionsGraph)

Wide format is generally better/closer to the typical JSON.

serialized,_ := json.Marshal(wide)

fmt.Println(string(serialized))

Directories

Path Synopsis
Package graphtweets provides an easy API to construct Twitter graphs.
Package graphtweets provides an easy API to construct Twitter graphs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL