Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johncoene/go-graphtweets
graphTweets for golang
https://github.com/johncoene/go-graphtweets
go golang social-network twitter
Last synced: about 1 month ago
JSON representation
graphTweets for golang
- Host: GitHub
- URL: https://github.com/johncoene/go-graphtweets
- Owner: JohnCoene
- License: mit
- Created: 2019-03-31T13:49:29.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-02T20:04:16.000Z (over 3 years ago)
- Last Synced: 2024-10-15T00:51:58.797Z (3 months ago)
- Topics: go, golang, social-network, twitter
- Language: Go
- Homepage: https://godoc.org/github.com/JohnCoene/go-graphtweets/graphtweets
- Size: 16.6 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Go Report Card](https://goreportcard.com/badge/github.com/JohnCoene/go-graphtweets)](https://goreportcard.com/report/github.com/JohnCoene/go-graphtweets) [![](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square)](https://pkg.go.dev/github.com/JohnCoene/go-graphtweets/graphtweets)
# go-graphtweets
Build Twitter networks.
_`go-graphtweets` is the sister of the [`graphTweets`](https://github.com/JohnCoene/graphTweets) R package._
## Install
Install `go-twitter`
```bash
go get github.com/dghubble/go-twitter/twitter
```Install `go-graphtweets`
```bash
go get github.com/JohnCoene/go-graphtweets/graphtweets
```## Documentation
The documentation is on [godoc](https://godoc.org/github.com/JohnCoene/go-graphtweets/graphtweets)
## Example
Set up `go-twitter` session.
```go
// 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.
```go
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.
```go
wide := graphtweets.ToWide(&mentionsGraph)
```Wide format is generally better/closer to the typical `JSON`.
```go
serialized,_ := json.Marshal(wide)fmt.Println(string(serialized))
```