twitter

package
v0.0.0-...-4ffe290 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Basic OAuth related URLs.
	OAUTH_REQUEST_TOKEN string = "https://api.twitter.com/oauth/request_token"
	OAUTH_AUTH_TOKEN    string = "https://api.twitter.com/oauth/authorize"
	OAUTH_ACCESS_TOKEN  string = "https://api.twitter.com/oauth/access_token"

	// List API URLs.
	API_BASE               string = "https://api.twitter.com/1.1/"
	API_VERIFY_CREDENTIALS string = API_BASE + "account/verify_credentials.json"
	API_TIMELINE           string = API_BASE + "statuses/home_timeline.json"
	API_FOLLOWERS_IDS      string = API_BASE + "followers/ids.json"
	API_FOLLOWERS_LIST     string = API_BASE + "followers/list.json"
	API_FOLLOWER_INFO      string = API_BASE + "users/show.json"
)

Variables

View Source
var OAuthConsumer *oauth.Consumer
View Source
var SessionKey = "twitter-state"
View Source
var SessionName = "kuber-twitter"
View Source
var Store = sessions.NewCookieStore([]byte("datalayer-session-secret"))

Functions

func FindAll

func FindAll() []interface{}

func FindBy

func FindBy(key string) (interface{}, bool)

func Remove

func Remove(key string)

func Save

func Save(key string, item interface{})

Types

type Client

type Client struct {
	HttpConn *http.Client
}

func (*Client) BasicQuery

func (c *Client) BasicQuery(queryString string) ([]byte, error)

func (*Client) HasAuth

func (c *Client) HasAuth() bool

func (*Client) QueryFollower

func (c *Client) QueryFollower(count int) (Followers, []byte, error)

func (*Client) QueryFollowerById

func (c *Client) QueryFollowerById(id int) (UserDetail, []byte, error)

func (*Client) QueryFollowerIDs

func (c *Client) QueryFollowerIDs(count int) (FollowerIDs, []byte, error)

func (*Client) QueryTimeLine

func (c *Client) QueryTimeLine(count int) (TimelineTweets, []byte, error)

func (*Client) VerifyCredentials

func (c *Client) VerifyCredentials() (UserDetail, []byte, error)

type DesktopClient

type DesktopClient struct {
	Client
	OAuthConsumer *oauth.Consumer
}

func NewDesktopClient

func NewDesktopClient(consumerKey, consumerSecret string) *DesktopClient

func (*DesktopClient) DoAuth

func (d *DesktopClient) DoAuth() error

type FollowerIDs

type FollowerIDs struct {
	Ids               []interface{} `json:"ids"`
	NextCursor        int64         `json:"next_cursor"`
	NextCursorStr     string        `json:"next_cursor_str"`
	PreviousCursor    int           `json:"previous_cursor"`
	PreviousCursorStr string        `json:"previous_cursor_str"`
}

type Followers

type Followers struct {
	Users []struct {
		ID                             int64       `json:"id"`
		IDStr                          string      `json:"id_str"`
		Name                           string      `json:"name"`
		ScreenName                     string      `json:"screen_name"`
		Location                       string      `json:"location"`
		ProfileLocation                interface{} `json:"profile_location"`
		URL                            interface{} `json:"url"`
		Description                    string      `json:"description"`
		Protected                      bool        `json:"protected"`
		FollowersCount                 int         `json:"followers_count"`
		FriendsCount                   int         `json:"friends_count"`
		ListedCount                    int         `json:"listed_count"`
		CreatedAt                      string      `json:"created_at"`
		FavouritesCount                int         `json:"favourites_count"`
		UtcOffset                      interface{} `json:"utc_offset"`
		TimeZone                       interface{} `json:"time_zone"`
		GeoEnabled                     bool        `json:"geo_enabled"`
		Verified                       bool        `json:"verified"`
		StatusesCount                  int         `json:"statuses_count"`
		Lang                           string      `json:"lang"`
		ContributorsEnabled            bool        `json:"contributors_enabled"`
		IsTranslator                   bool        `json:"is_translator"`
		IsTranslationEnabled           bool        `json:"is_translation_enabled"`
		ProfileBackgroundColor         string      `json:"profile_background_color"`
		ProfileBackgroundImageURL      string      `json:"profile_background_image_url"`
		ProfileBackgroundImageURLHTTPS string      `json:"profile_background_image_url_https"`
		ProfileBackgroundTile          bool        `json:"profile_background_tile"`
		ProfileImageURL                string      `json:"profile_image_url"`
		ProfileImageURLHTTPS           string      `json:"profile_image_url_https"`
		ProfileLinkColor               string      `json:"profile_link_color"`
		ProfileSidebarBorderColor      string      `json:"profile_sidebar_border_color"`
		ProfileSidebarFillColor        string      `json:"profile_sidebar_fill_color"`
		ProfileTextColor               string      `json:"profile_text_color"`
		ProfileUseBackgroundImage      bool        `json:"profile_use_background_image"`
		DefaultProfile                 bool        `json:"default_profile"`
		DefaultProfileImage            bool        `json:"default_profile_image"`
		Following                      bool        `json:"following"`
		FollowRequestSent              bool        `json:"follow_request_sent"`
		Notifications                  bool        `json:"notifications"`
		Muting                         bool        `json:"muting"`
	} `json:"users"`
	NextCursor        int64  `json:"next_cursor"`
	NextCursorStr     string `json:"next_cursor_str"`
	PreviousCursor    int    `json:"previous_cursor"`
	PreviousCursorStr string `json:"previous_cursor_str"`
}

type TimelineTweets

type TimelineTweets []struct {
	CreatedAt            string      `json:"created_at"`
	ID                   int64       `json:"id"`
	IDStr                string      `json:"id_str"`
	Text                 string      `json:"text"`
	Source               string      `json:"source"`
	Truncated            bool        `json:"truncated"`
	InReplyToStatusID    interface{} `json:"in_reply_to_status_id"`
	InReplyToStatusIDStr interface{} `json:"in_reply_to_status_id_str"`
	InReplyToUserID      interface{} `json:"in_reply_to_user_id"`
	InReplyToUserIDStr   interface{} `json:"in_reply_to_user_id_str"`
	InReplyToScreenName  interface{} `json:"in_reply_to_screen_name"`
	User                 struct {
		ID          int    `json:"id"`
		IDStr       string `json:"id_str"`
		Name        string `json:"name"`
		ScreenName  string `json:"screen_name"`
		Location    string `json:"location"`
		Description string `json:"description"`
		URL         string `json:"url"`
		Entities    struct {
			URL struct {
				Urls []struct {
					URL         string `json:"url"`
					ExpandedURL string `json:"expanded_url"`
					DisplayURL  string `json:"display_url"`
					Indices     []int  `json:"indices"`
				} `json:"urls"`
			} `json:"url"`
			Description struct {
				Urls []interface{} `json:"urls"`
			} `json:"description"`
		} `json:"entities"`
		Protected                      bool   `json:"protected"`
		FollowersCount                 int    `json:"followers_count"`
		FriendsCount                   int    `json:"friends_count"`
		ListedCount                    int    `json:"listed_count"`
		CreatedAt                      string `json:"created_at"`
		FavouritesCount                int    `json:"favourites_count"`
		UtcOffset                      int    `json:"utc_offset"`
		TimeZone                       string `json:"time_zone"`
		GeoEnabled                     bool   `json:"geo_enabled"`
		Verified                       bool   `json:"verified"`
		StatusesCount                  int    `json:"statuses_count"`
		Lang                           string `json:"lang"`
		ContributorsEnabled            bool   `json:"contributors_enabled"`
		IsTranslator                   bool   `json:"is_translator"`
		IsTranslationEnabled           bool   `json:"is_translation_enabled"`
		ProfileBackgroundColor         string `json:"profile_background_color"`
		ProfileBackgroundImageURL      string `json:"profile_background_image_url"`
		ProfileBackgroundImageURLHTTPS string `json:"profile_background_image_url_https"`
		ProfileBackgroundTile          bool   `json:"profile_background_tile"`
		ProfileImageURL                string `json:"profile_image_url"`
		ProfileImageURLHTTPS           string `json:"profile_image_url_https"`
		ProfileBannerURL               string `json:"profile_banner_url"`
		ProfileLinkColor               string `json:"profile_link_color"`
		ProfileSidebarBorderColor      string `json:"profile_sidebar_border_color"`
		ProfileSidebarFillColor        string `json:"profile_sidebar_fill_color"`
		ProfileTextColor               string `json:"profile_text_color"`
		ProfileUseBackgroundImage      bool   `json:"profile_use_background_image"`
		HasExtendedProfile             bool   `json:"has_extended_profile"`
		DefaultProfile                 bool   `json:"default_profile"`
		DefaultProfileImage            bool   `json:"default_profile_image"`
		Following                      bool   `json:"following"`
		FollowRequestSent              bool   `json:"follow_request_sent"`
		Notifications                  bool   `json:"notifications"`
	} `json:"user"`
	Geo           interface{} `json:"geo"`
	Coordinates   interface{} `json:"coordinates"`
	Place         interface{} `json:"place"`
	Contributors  interface{} `json:"contributors"`
	IsQuoteStatus bool        `json:"is_quote_status"`
	RetweetCount  int         `json:"retweet_count"`
	FavoriteCount int         `json:"favorite_count"`
	Entities      struct {
		Hashtags     []interface{} `json:"hashtags"`
		Symbols      []interface{} `json:"symbols"`
		UserMentions []interface{} `json:"user_mentions"`
		Urls         []interface{} `json:"urls"`
	} `json:"entities"`
	Favorited bool   `json:"favorited"`
	Retweeted bool   `json:"retweeted"`
	Lang      string `json:"lang"`
}

type TwitterResource

type TwitterResource struct {
}

func (TwitterResource) GetMe

func (t TwitterResource) GetMe(request *restful.Request, response *restful.Response)

func (TwitterResource) GetTwitterToken

func (t TwitterResource) GetTwitterToken(request *restful.Request, response *restful.Response)

func (TwitterResource) RedirecToTwitter

func (t TwitterResource) RedirecToTwitter(request *restful.Request, response *restful.Response)

func (TwitterResource) WebService

func (t TwitterResource) WebService() *restful.WebService

type TwitterSession

type TwitterSession struct {
	Client
	OAuthTokens map[string]*oauth.RequestToken
	Clients     map[string]Client
}

func NewTwitterSession

func NewTwitterSession(consumerKey, consumerSecret string) *TwitterSession

func (*TwitterSession) CompleteAuth

func (s *TwitterSession) CompleteAuth(tokenKey, verificationCode string) (Client, *oauth.AccessToken, error)

func (*TwitterSession) GetAuthURL

func (s *TwitterSession) GetAuthURL(tokenUrl string) string

type TwitterUser

type TwitterUser struct {
	Username           string `json:"username"`
	Oauth_token        string `json:"oauth_token"`
	Oauth_verifier     string `json:"oauth_verifier"`
	Oauth_access_token string `json:"oauth_access_token"`
	IsAuth             bool   `json:"isAuth"`
}

type UserDetail

type UserDetail struct {
	ContributorsEnabled bool   `json:"contributors_enabled"`
	CreatedAt           string `json:"created_at"`
	DefaultProfile      bool   `json:"default_profile"`
	DefaultProfileImage bool   `json:"default_profile_image"`
	Description         string `json:"description"`
	Entities            struct {
		Description struct {
			Urls []interface{} `json:"urls"`
		} `json:"description"`
		URL struct {
			Urls []struct {
				DisplayURL  string `json:"display_url"`
				ExpandedURL string `json:"expanded_url"`
				Indices     []int  `json:"indices"`
				URL         string `json:"url"`
			} `json:"urls"`
		} `json:"url"`
	} `json:"entities"`
	FavouritesCount                int         `json:"favourites_count"`
	FollowRequestSent              bool        `json:"follow_request_sent"`
	FollowersCount                 int         `json:"followers_count"`
	Following                      bool        `json:"following"`
	FriendsCount                   int         `json:"friends_count"`
	GeoEnabled                     bool        `json:"geo_enabled"`
	ID                             int64       `json:"id"`
	IDStr                          string      `json:"id_str"`
	IsTranslationEnabled           bool        `json:"is_translation_enabled"`
	IsTranslator                   bool        `json:"is_translator"`
	Lang                           string      `json:"lang"`
	ListedCount                    int         `json:"listed_count"`
	Location                       string      `json:"location"`
	Name                           string      `json:"name"`
	Notifications                  bool        `json:"notifications"`
	ProfileBackgroundColor         string      `json:"profile_background_color"`
	ProfileBackgroundImageURL      string      `json:"profile_background_image_url"`
	ProfileBackgroundImageURLHTTPS string      `json:"profile_background_image_url_https"`
	ProfileBackgroundTile          bool        `json:"profile_background_tile"`
	ProfileBannerURL               string      `json:"profile_banner_url"`
	ProfileImageURL                string      `json:"profile_image_url"`
	ProfileImageURLHTTPS           string      `json:"profile_image_url_https"`
	ProfileLinkColor               string      `json:"profile_link_color"`
	ProfileLocation                interface{} `json:"profile_location"`
	ProfileSidebarBorderColor      string      `json:"profile_sidebar_border_color"`
	ProfileSidebarFillColor        string      `json:"profile_sidebar_fill_color"`
	ProfileTextColor               string      `json:"profile_text_color"`
	ProfileUseBackgroundImage      bool        `json:"profile_use_background_image"`
	Protected                      bool        `json:"protected"`
	ScreenName                     string      `json:"screen_name"`
	Status                         struct {
		Contributors interface{} `json:"contributors"`
		Coordinates  interface{} `json:"coordinates"`
		CreatedAt    string      `json:"created_at"`
		Entities     struct {
			Hashtags []interface{} `json:"hashtags"`
			Symbols  []interface{} `json:"symbols"`
			Urls     []struct {
				DisplayURL  string `json:"display_url"`
				ExpandedURL string `json:"expanded_url"`
				Indices     []int  `json:"indices"`
				URL         string `json:"url"`
			} `json:"urls"`
			UserMentions []struct {
				ID         int    `json:"id"`
				IDStr      string `json:"id_str"`
				Indices    []int  `json:"indices"`
				Name       string `json:"name"`
				ScreenName string `json:"screen_name"`
			} `json:"user_mentions"`
		} `json:"entities"`
		FavoriteCount        int         `json:"favorite_count"`
		Favorited            bool        `json:"favorited"`
		Geo                  interface{} `json:"geo"`
		ID                   int64       `json:"id"`
		IDStr                string      `json:"id_str"`
		InReplyToScreenName  interface{} `json:"in_reply_to_screen_name"`
		InReplyToStatusID    interface{} `json:"in_reply_to_status_id"`
		InReplyToStatusIDStr interface{} `json:"in_reply_to_status_id_str"`
		InReplyToUserID      interface{} `json:"in_reply_to_user_id"`
		InReplyToUserIDStr   interface{} `json:"in_reply_to_user_id_str"`
		Lang                 string      `json:"lang"`
		Place                interface{} `json:"place"`
		PossiblySensitive    bool        `json:"possibly_sensitive"`
		RetweetCount         int         `json:"retweet_count"`
		Retweeted            bool        `json:"retweeted"`
		RetweetedStatus      struct {
			Contributors interface{} `json:"contributors"`
			Coordinates  interface{} `json:"coordinates"`
			CreatedAt    string      `json:"created_at"`
			Entities     struct {
				Hashtags []interface{} `json:"hashtags"`
				Symbols  []interface{} `json:"symbols"`
				Urls     []struct {
					DisplayURL  string `json:"display_url"`
					ExpandedURL string `json:"expanded_url"`
					Indices     []int  `json:"indices"`
					URL         string `json:"url"`
				} `json:"urls"`
				UserMentions []interface{} `json:"user_mentions"`
			} `json:"entities"`
			FavoriteCount        int         `json:"favorite_count"`
			Favorited            bool        `json:"favorited"`
			Geo                  interface{} `json:"geo"`
			ID                   int64       `json:"id"`
			IDStr                string      `json:"id_str"`
			InReplyToScreenName  interface{} `json:"in_reply_to_screen_name"`
			InReplyToStatusID    interface{} `json:"in_reply_to_status_id"`
			InReplyToStatusIDStr interface{} `json:"in_reply_to_status_id_str"`
			InReplyToUserID      interface{} `json:"in_reply_to_user_id"`
			InReplyToUserIDStr   interface{} `json:"in_reply_to_user_id_str"`
			Lang                 string      `json:"lang"`
			Place                interface{} `json:"place"`
			PossiblySensitive    bool        `json:"possibly_sensitive"`
			RetweetCount         int         `json:"retweet_count"`
			Retweeted            bool        `json:"retweeted"`
			Source               string      `json:"source"`
			Text                 string      `json:"text"`
			Truncated            bool        `json:"truncated"`
		} `json:"retweeted_status"`
		Source    string `json:"source"`
		Text      string `json:"text"`
		Truncated bool   `json:"truncated"`
	} `json:"status"`
	StatusesCount int    `json:"statuses_count"`
	TimeZone      string `json:"time_zone"`
	URL           string `json:"url"`
	UtcOffset     int    `json:"utc_offset"`
	Verified      bool   `json:"verified"`
}

Jump to

Keyboard shortcuts

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