twitter

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	ConsumerKey       string
	ConsumerSecret    string
	AccessToken       string
	AccessTokenSecret string
}

Credentials contains the authentication credentials needed for twitter api access

ConsumerKey and ConsumerSecret can be thought of as the user name and password that represents your Twitter developer app when making API requests.

An access token and access token secret are user-specific credentials used to authenticate OAuth 1.0a API requests. They specify the Twitter account the request is made on behalf of.

See https://developer.twitter.com/en/docs/authentication/oauth-1-0a for more details

type Twitter

type Twitter struct {
	// contains filtered or unexported fields
}

Twitter struct holds necessary data to communicate with the Twitter API

func New

func New(credentials Credentials) (*Twitter, error)

New returns a new instance of a Twitter service. For more information about Twitter access token:

-> https://developer.twitter.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens

func NewWithHttpClient added in v0.43.0

func NewWithHttpClient(credentials Credentials, h *http.Client) (*Twitter, error)

func (*Twitter) AddReceivers

func (t *Twitter) AddReceivers(twitterIDs ...string)

AddReceivers takes TwitterIds and adds them to the internal twitterIDs list.

func (Twitter) Send

func (t Twitter) Send(ctx context.Context, subject, message string) error

Send takes a message subject and a message body and sends them to all previously set twitterIDs as a DM. See https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/new-event

Jump to

Keyboard shortcuts

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