reddit

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthToken

type AuthToken struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	DeviceId    string `json:"device_id"`
	ExpiresIn   int    `json:"expires_in"`
	Scope       string `json:"scope"`
}

func GetAuthToken

func GetAuthToken(appId, appSecret string) (token AuthToken, err error)

type Comment

type Comment struct {
	Id      string    `json:"id"`
	Body    string    `json:"body"`
	Ups     int       `json:"ups"`
	Downs   int       `json:"downs"`
	Score   int       `json:"score"`
	Created time.Time `json:"created_utc"`
	Depth   int       `json:"depth"`
	Author  string    `json:"author"`

	// Parent and children needs to be filled in after struct has been unmarshalled
	//Parent   *Comment   `json:"-"`
	Replies []Comment `json:"replies"`
}

func FetchPostComments

func FetchPostComments(p Post, authorization AuthToken) (c []Comment, err error)

type Post

type Post struct {
	Subreddit    string    `json:"subreddit"`
	Title        string    `json:"title"`
	Body         string    `json:"selftext"`
	Ups          int       `json:"ups"`
	Downs        int       `json:"downs"`
	Score        int       `json:"score"`
	UpvoteRatio  float64   `json:"upvote_ratio"`
	Created      float64   `json:"created_utc"`
	Author       string    `json:"author"`
	Permalink    string    `json:"permalink"`
	NumComments  int       `json:"num_comments"`
	Comments     []Comment `json:"comments"`
	DownloadTime time.Time `json:"-"`
}

func GetHot

func GetHot(subreddit string, limit int, authorization AuthToken) ([]Post, error)

func GetNew

func GetNew(subreddit string, limit int, authorization AuthToken) ([]Post, error)

func GetPosts

func GetPosts(subreddit string, limit int, sort string, authorization AuthToken) (posts []Post, err error)

func GetRising

func GetRising(subreddit string, limit int, authorization AuthToken) ([]Post, error)

func GetTop

func GetTop(subreddit string, limit int, authorization AuthToken) ([]Post, error)

Jump to

Keyboard shortcuts

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