twitter

package
v0.0.0-...-74ff373 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package twitter partially implements the Twitter API.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidImage is returned when an image is invalid.
	ErrInvalidImage = errors.New("twitter: invalid image provided")
)
View Source
var ErrInvalidUser = errors.New("twitter: invalid user provided")

ErrInvalidUser is returned when no user is provided.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Errors []ErrorDetail `json:"errors"`
}

APIError is the response from Twitter's API when an error occurs.

func (APIError) Error

func (e APIError) Error() string

Error implements the error interface.

type Config

type Config struct {
	ConsumerKey      string
	ConsumerSecret   string
	OAuthToken       string
	OAuthTokenSecret string
}

Config configures a Twitter client for use in interacting with the Twitter API.

type ErrorDetail

type ErrorDetail struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

ErrorDetail details what went wrong when the Twitter API returns an error.

type Settings

type Settings struct {
	ScreenName string `json:"screen_name"`
}

Settings partially defines the account setting object returned by the Twitter API.

type Twitter

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

Twitter is an HTTP client responsible for interacting with the Twitter API.

func New

func New(conf Config) *Twitter

New creates a new Twitter client.

func (*Twitter) GetAccountSettings

func (t *Twitter) GetAccountSettings() (*Settings, error)

GetAccountSettings retrieves the authenticated account's settings from Twitter's API.

func (*Twitter) UpdateProfileImage

func (t *Twitter) UpdateProfileImage(image string) error

UpdateProfileImage uploads a new profile image to the authenticated user's account.

func (*Twitter) UserShow

func (t *Twitter) UserShow(screenName string) (*User, error)

UserShow retrieves a user from Twitter's API.

type User

type User struct {
	ProfileImageURLHTTPS string `json:"profile_image_url_https"`
	DefaultProfileImage  bool   `json:"default_profile_image"`
}

User is a partial definition of a Twitter user.

Jump to

Keyboard shortcuts

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