Documentation ¶
Overview ¶
Package quitter is a Go library to interact with GNU Social instances.
The MIT License (MIT) Copyright (c) 2016 aerth Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Example ¶
package main import ( "fmt" "os" quitter "github.com/aerth/go-quitter" ) func main() { q := quitter.NewSocial() q.Username = "username" q.Password = "password" q.Node = "localhost" quips, err := q.GetHome() if err != nil { fmt.Println(err) os.Exit(1) } for _, quip := range quips { fmt.Printf("%s %s", quip.IdStr, quip.Text) } }
Output:
Index ¶
- type Badrequest
- type Group
- type Quip
- type Social
- func (a Social) DoFollow(followstr string) (user User, err error)
- func (a Social) DoPublicSearch(searchstr string) ([]Quip, error)
- func (a Social) DoSearch(searchstr string) ([]Quip, error)
- func (a Social) DoUnfollow(followstr string) (user User, err error)
- func (a Social) FireGET(path string) ([]byte, error)
- func (a Social) FirePOST(path string, v url.Values) ([]byte, error)
- func (a Social) GetHome() ([]Quip, error)
- func (a Social) GetMentions() ([]Quip, error)
- func (a Social) GetPublic() ([]Quip, error)
- func (a Social) GetUserTimeline(userlookup string) ([]Quip, error)
- func (a Social) JoinGroup(grp string) (g Group, err error)
- func (a Social) ListAllGroups() ([]Group, error)
- func (a Social) ListMyGroups() ([]Group, error)
- func (a Social) PartGroup(grp string) (g Group, err error)
- func (a Social) PostNew(content string) (q Quip, err error)
- type User
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Badrequest ¶
Badrequest is an error. If the API doesn't respond how we like, it replies using this struct (in json)
type Group ¶ added in v0.0.5
type Group struct { Id int64 `json:"id"` Url string `json:"url"` Nickname string `json:"nickname"` Fullname string `json:"fullname"` Member bool `json:"member"` Membercount int64 `json:"member_count"` Description string `json:"description"` }
Group is a GNU Social Group, gets returned by GS API.
type Quip ¶ added in v0.0.8
type Quip struct { Id int64 `json:"id"` IdStr string `json:"id_str"` InReplyToScreenName string `json:"in_reply_to_screen_name"` InReplyToStatusID int64 `json:"in_reply_to_status_id"` InReplyToStatusIdStr string `json:"in_reply_to_status_id_str"` InReplyToUserID int64 `json:"in_reply_to_user_id"` InReplyToUserIdStr string `json:"in_reply_to_user_id_str"` Lang string `json:"lang"` Place string `json:"place"` PossiblySensitive bool `json:"possibly_sensitive"` RetweetCount int `json:"retweet_count"` Retweeted bool `json:"retweeted"` RetweetedStatus *Quip `json:"retweeted_status"` Source string `json:"source"` Text string `json:"text"` Truncated bool `json:"truncated"` User User `json:"user"` WithheldCopyright bool `json:"withheld_copyright"` WithheldInCountries []string `json:"withheld_in_countries"` WithheldScope string `json:"withheld_scope"` }
Quip is a GNU Social Quip, gets returned by GS API.
type Social ¶ added in v0.0.9
Social is credentials needed for logging in. Set it with NewSocial()
func NewSocial ¶ added in v0.0.9
func NewSocial() *Social
Sets the authentication method and choose node. Use like this:
q := qw.NewSocial() q.Username = "john" q.Password = "pass123" q.Node = "gnusocial.de" q.GetHome(false)
Example ¶
package main import ( "fmt" "os" quitter "github.com/aerth/go-quitter" ) func main() { q := quitter.NewSocial() q.Username = "username" q.Password = "password" q.Node = "localhost" quips, err := q.GetHome() if err != nil { fmt.Println(err) os.Exit(1) } for _, quip := range quips { fmt.Printf("%s %s", quip.IdStr, quip.Text) } }
Output:
func (Social) DoPublicSearch ¶ added in v0.0.9
DoPublicSearch returns results for query searchstr. Does not send auth info.
func (Social) DoSearch ¶ added in v0.0.9
DoSearch returns results for query searchstr. Does send auth info.
func (Social) DoUnfollow ¶ added in v0.0.9
DoUnfollow sends a request to unfollow a user
func (Social) GetMentions ¶ added in v0.0.9
GetMentions shows 20 newest mentions of your username.
func (Social) GetPublic ¶ added in v0.0.9
GetPublic shows 20 new messages.
Example ¶
package main import ( "fmt" "os" quitter "github.com/aerth/go-quitter" ) func main() { q := quitter.NewSocial() q.Username = "username" q.Password = "password" q.Node = "localhost" quips, err := q.GetPublic() if err != nil { fmt.Println(err) os.Exit(1) } for _, quip := range quips { fmt.Printf("%s %s", quip.IdStr, quip.Text) } }
Output:
func (Social) GetUserTimeline ¶ added in v0.0.9
GetUserTimeline returns a userlookup's timeline
func (Social) ListAllGroups ¶ added in v0.0.9
ListAllGroups lists each group in a.Node Some nodes don't return anything.
func (Social) ListMyGroups ¶ added in v0.0.9
ListMyGroups lists each group a a.Username is a member of
func (Social) PostNew ¶ added in v0.0.9
PostNew publishes content on a.Node, returns the new quip or an error.
Example ¶
package main import ( "fmt" "os" quitter "github.com/aerth/go-quitter" ) func main() { q := quitter.NewSocial() q.Username = "username" q.Password = "password" q.Node = "localhost" content := ` dang this is a " < new > ! quip about to be published>>><><><?><?><?><<?><?><?><?><?><?><?><?><"` quip, err := q.PostNew(content) if err != nil { fmt.Println(err) os.Exit(1) } fmt.Printf("%s %s", quip.IdStr, quip.Text) }
Output: