Documentation ¶
Index ¶
- Constants
- Variables
- func Configure(confs ProviderConfigs, tokenAuth *jwtauth.JWTAuth)
- func GetUTCTimeForLayout(timeStr string, layout string) (time.Time, error)
- func NewOAuth(providerID string) (social.OAuth, error)
- func Register(providerID string, provider *Provider)
- type Cursor
- type Error
- type OAuth1Creds
- func (c *OAuth1Creds) AccessToken() string
- func (c *OAuth1Creds) AccessTokenSecret() string
- func (c *OAuth1Creds) ExpiresAt() *time.Time
- func (c *OAuth1Creds) Permission() social.Permission
- func (c *OAuth1Creds) ProviderID() string
- func (c *OAuth1Creds) ProviderUserID() string
- func (c *OAuth1Creds) RefreshToken() string
- func (c *OAuth1Creds) SetPermission(perm string)
- type OAuth2Creds
- func (c *OAuth2Creds) AccessToken() string
- func (c *OAuth2Creds) AccessTokenSecret() string
- func (c *OAuth2Creds) ExpiresAt() *time.Time
- func (c *OAuth2Creds) Permission() social.Permission
- func (c *OAuth2Creds) ProviderID() string
- func (c *OAuth2Creds) ProviderUserID() string
- func (c *OAuth2Creds) RefreshToken() string
- func (c *OAuth2Creds) SetPermission(perm string)
- type Provider
- type ProviderConfig
- type ProviderConfigs
- type ProviderSession
- type Query
- type SearchParts
Constants ¶
View Source
const ( DefaultNumResults = 20 MaxNumResults = 50 )
Variables ¶
View Source
var ( ErrUnknownProviderID = &Error{Code: 1, Msg: "unknown provider id"} // Authorization ErrNoCredentials = &Error{Code: 1000, Msg: "missing provider credentials, please connect your social account first"} ErrAuthFailed = &Error{Code: 1001, Msg: "provider authorization failed, please re-connect your social account"} ErrInvalidToken = &Error{Code: 1002, Msg: "invalid provider token, please re-connect your social account"} ErrExpiredToken = &Error{Code: 1003, Msg: "expired provider token, please re-connect your social account"} ErrHitRateLimit = &Error{Code: 1004, Msg: "hit token rate limit"} ErrBadAccount = &Error{Code: 1005, Msg: "disabled account"} ErrMustReauth = &Error{Code: 1006, Msg: "authentication error, please re-connect your social account"} ErrGetUser = &Error{Code: 1007, Msg: "unable to fetch user profile"} ErrEmptyCode = &Error{Code: 1008, Msg: "empty code in callback"} // Queries ErrInvalidQuery = &Error{Code: 2000, Msg: "invalid request query"} ErrNoQueryAccess = &Error{Code: 2001, Msg: "provider does not have access for this query"} ErrInvalidAsset = &Error{Code: 2002, Msg: "invalid asset"} ErrWritingPost = &Error{Code: 2003, Msg: "unable to post asset"} ErrDuplicatePost = &Error{Code: 2004, Msg: "duplicate post"} ErrUsernameSearch = &Error{Code: 2005, Msg: "provided doesn't allow @username searches, @page (brand) searches work"} // Everything else ErrUnknown = &Error{Code: 5000, Msg: "unknown provider error"} ErrProviderDown = &Error{Code: 5001, Msg: "provider is down"} ErrUnsupported = &Error{Code: 5002, Msg: "unsupported operation"} ErrNotImplemented = &Error{Code: 5003, Msg: "not implemented"} ErrInvalidContent = &Error{Code: 5004, Msg: "empty title and url provided"} )
TODO: We need iota-style error codes, so we can catch'em in the below layers easily.
View Source
var (
NoQuery = Query{}
)
View Source
var Registry = make(map[string]*Provider)
View Source
var TokenAuth *jwtauth.JWTAuth
Functions ¶
func Configure ¶
func Configure(confs ProviderConfigs, tokenAuth *jwtauth.JWTAuth)
func GetUTCTimeForLayout ¶
Types ¶
type Error ¶
type Error struct { Code int // provider error code Msg string // provider error string // contains filtered or unexported fields }
Provider-specific error
type OAuth1Creds ¶
type OAuth1Creds struct { CredProviderID string CredProviderUserID string CredAccessToken string CredAccessTokenSecret string CredRefreshToken string CredExpiresAt *time.Time CredPermission social.Permission }
OAuth1Creds is a normalized social.Credentials implementation to use with social providers using oauth1 (ie. twitter)
func (*OAuth1Creds) AccessToken ¶
func (c *OAuth1Creds) AccessToken() string
func (*OAuth1Creds) AccessTokenSecret ¶
func (c *OAuth1Creds) AccessTokenSecret() string
func (*OAuth1Creds) ExpiresAt ¶
func (c *OAuth1Creds) ExpiresAt() *time.Time
func (*OAuth1Creds) Permission ¶
func (c *OAuth1Creds) Permission() social.Permission
func (*OAuth1Creds) ProviderID ¶
func (c *OAuth1Creds) ProviderID() string
func (*OAuth1Creds) ProviderUserID ¶
func (c *OAuth1Creds) ProviderUserID() string
func (*OAuth1Creds) RefreshToken ¶
func (c *OAuth1Creds) RefreshToken() string
func (*OAuth1Creds) SetPermission ¶
func (c *OAuth1Creds) SetPermission(perm string)
type OAuth2Creds ¶
type OAuth2Creds struct { *oauth2.Token CredProviderID string CredProviderUserID string CredPermission social.Permission }
OAuth2Creds is a normalized social.Credentials implementation to use with social providers using oauth2 (ie. facebook, google, ..)
func (*OAuth2Creds) AccessToken ¶
func (c *OAuth2Creds) AccessToken() string
func (*OAuth2Creds) AccessTokenSecret ¶
func (c *OAuth2Creds) AccessTokenSecret() string
func (*OAuth2Creds) ExpiresAt ¶
func (c *OAuth2Creds) ExpiresAt() *time.Time
func (*OAuth2Creds) Permission ¶
func (c *OAuth2Creds) Permission() social.Permission
func (*OAuth2Creds) ProviderID ¶
func (c *OAuth2Creds) ProviderID() string
func (*OAuth2Creds) ProviderUserID ¶
func (c *OAuth2Creds) ProviderUserID() string
func (*OAuth2Creds) RefreshToken ¶
func (c *OAuth2Creds) RefreshToken() string
func (*OAuth2Creds) SetPermission ¶
func (c *OAuth2Creds) SetPermission(perm string)
type ProviderConfig ¶
type ProviderConfigs ¶
type ProviderConfigs map[string]ProviderConfig
type ProviderSession ¶
type ProviderSession interface { // ID of the Provider ID() string // Post a message to the provider and return the new Post object created. Post(ctx context.Context, msg string, link string) (*social.Post, error) // Search content on a provider network Search(query Query) (social.Posts, *Cursor, error) // Get a user's feed/wall GetFeed(query Query) (social.Posts, *Cursor, error) // Feed // Get a user's own posts GetPosts(query Query) (social.Posts, *Cursor, error) // Posts // Get the user social profile object GetUser(query Query) (*social.User, error) // Get a user's friends list (aka following) GetFriends(query Query) ([]*social.User, *Cursor, error) // Get a user's followers list GetFollowers(query Query) ([]*social.User, *Cursor, error) }
func NewSession ¶
func NewSession(ctx context.Context, providerID string, creds social.Credentials) (ProviderSession, error)
type Query ¶
type Query struct { Search SearchParts Filter string // Second-pass keywords filter Username string // Query by a specific username UserID string Limit int Sort string // recent,popular (default: recent) SinceID string // TODO: rename these to NextID and PrevID? UntilID string Perm string // read or write, default: read Params url.Values }
TODO: use https://github.com/google/go-querystring with `url` struct tags to easier parse/build query strings
type SearchParts ¶
type SearchParts struct {
Usernames, Tags, Words []string
}
Search query parts
func NewSearchParts ¶
func NewSearchParts(q string) SearchParts
func (SearchParts) Keywords ¶
func (sq SearchParts) Keywords(prefix ...bool) (s string)
Return only the tags and words in the search query
func (SearchParts) String ¶
func (sq SearchParts) String() (s string)
func (SearchParts) Username ¶
func (sq SearchParts) Username() (s string)
Returns the first username found
Source Files ¶
Click to show internal directories.
Click to hide internal directories.