go-twitter

module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: MIT

README

go-twitter

A simple Go wrapper for Twitter API v2 ✨ 🍰 ✨

Test Status Test Coverage Go Report Card Go Reference

Installation

# Go Modules
require github.com/sns-sdks/go-twitter

Usage

App with OAuth 2.0

Construct a new client with bearer token, then use the api.

cli := twitter.NewBearerClient("your bearer token")
u, err := cli.Tweets.LookupByID("tweet id", twitter.TweetOpts{})
fmt.Println(u, err)

OAuth 2.0 has released with beta.

So you can do OAuth2.0 with twitter. More see the Example for OAuth2.0

Authentication

Some apis need OAuth 1.0a User context, You can use initial a client with user access token.

app := twitter.NewAuthorizationAPP(
	twitter.AuthorizationAPP{
		ConsumerKey:       "consumer key",
		ConsumerSecret:    "consumer secret",
		AccessTokenKey:    "user access token key",
		AccessTokenSecret: "user access toke secret",
    })
cli := app.GetUserClient()
bu, err := cli.Users.GetBlocking(uid, twitter.UserBlockingOpts{})
fmt.Println(bu, err)

Or you can handle authentication contact with twitter. See the Example for OAuth 1.0a

Features

Tweets:

  • Tweets lookup
  • Manage Tweets
  • Timelines
  • search Tweets
  • Tweet counts
  • Retweets
  • Likes
  • Hide replies

Users:

  • Users lookup
  • Follows
  • Blocks
  • Mutes

Spaces:

  • Lookup
  • Search

Lists:

  • List lookup
  • Manage lists
  • List Tweets lookup
  • List members
  • List follows
  • Pinned Lists

Compliance:

  • Batch compliance

Direct Message:

  • Direct Messages lookup
  • Manage Direct Messages

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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