ninegago

package module
v0.0.0-...-f5ac79a Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2017 License: MIT Imports: 13 Imported by: 0

README

ninegago

Unofficial 9GAG API, written in pure Go.

This couldn't be possible without the great work from @and3rson. Please check out his API example written on Python here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	AppToken   string
	DeviceUUID string
	User       *UserData
}

APIClient describes 9gag client

func NewAPIClient

func NewAPIClient() *APIClient

NewAPIClient returns new APIClient instance

func (*APIClient) GetHotPosts

func (c *APIClient) GetHotPosts(sectionType string, count int) (posts []PostData, err error)

GetHotPosts retreives N top posts from chosen section Returns slice of posts and error

func (*APIClient) Login

func (c *APIClient) Login(username, password string) (err error)

Login authenticates to 9GAG Returns user data and error

type Image

type Image struct {
	Width       int    `json:"width"`
	Height      int    `json:"height"`
	URL         string `json:"url"`
	Mask        string `json:"mask"`
	Placeholder string `json:"placeholder"`
}

Image describes image data from PostData

type LoginData

type LoginData struct {
	DummyField        string   `json:"dummyField"` // always equals to "dummyValue"
	MinVersion        string   `json:"minVersion"`
	UserToken         string   `json:"userToken"`
	TokenExpiry       int64    `json:"tokenExpiry"`
	SecondsTillExpiry int64    `json:"secondsTillExpiry"`
	AlgoliaToken      string   `json:"algoliaToken"`
	User              UserData `json:"user"`
}

LoginData describes login data from LoginResponse

type MetaData

type MetaData struct {
	Timestamp int64  `json:"timestamp"`
	Status    string `json:"status"`
	SID       string `json:"sid"`
}

MetaData describes meta data from every API response

type PostData

type PostData struct {
	ID             string `json:"id"`
	URL            string `json:"url"`
	Status         string `json:"status"`
	Title          string `json:"title"`
	Description    string `json:"description"`
	Type           string `json:"type"`
	Version        byte   `json:"version"`
	NSFW           byte   `json:"nsfw"`
	UpVoteCount    int    `json:"upVoteCount"`
	DownVoteCount  int    `json:"downVoteCount"`
	TotalVoteCount int    `json:"totalVoteCount"`
	ViewsCount     int    `json:"viewsCount"`
	Score          int    `json:"score"`
	ReportedStatus byte   `json:"reportedStatus"`
	CreationTs     int64  `json:"creationTs"`
	AlbumWebURL    string `json:"albumWebUrl"`
	HasImageTile   byte   `json:"hasImageTile"`
	// PostTile struct
	SortTs           int  `json:"sortTs"`
	OrderID          int  `json:"orderId"`
	HasLongPostCover byte `json:"hasLongPostCover"`
	Images           struct {
		Image700         Image `json:"image700"`
		Image460         Image `json:"image460"`
		Image220x145     Image `json:"image220x145"`
		ImageFbThumbnail Image `json:"imageFbThumbnail"`
	} `json:"images"`
	SourceDomain       string `json:"sourceDomain"`
	SourceURL          string `json:"sourceUrl"`
	ExternalURL        string `json:"externalUrl"`
	Channel            string `json:"channel"`
	IsVoted            string `json:"isVoted"`
	UserScore          int    `json:"userScore"`
	CommentOpClientID  string `json:"commentOpClientId"`
	CommentOpSignature string `json:"commentOpSignature"`
	// Creator struct
	CommentsCount int    `json:"commentsCount"`
	FbShares      int    `json:"fbShares"`
	TweetCount    int    `json:"tweetCount"`
	Created       string `json:"created"`
	CommentSystem string `json:"commentSystem"`
	// TopComments struct
	// TargetedAdTags struct
	Sections []string `json:"sections"`
	Tags     []Tag    `json:"tags"`
}

PostData describes post from PostListData

type PostListData

type PostListData struct {
	DummyField   string     `json:"dummyField"` // always equals to "dummyValue"
	DidEndOfList byte       `json:"didEndOfList"`
	Posts        []PostData `json:"posts"`
}

PostListData describes post list data from PostListResponse

type Tag

type Tag struct {
	Key string `json:"key"`
	URL string `json:"url"`
}

Tag describes tag data from PostData

type UserData

type UserData struct {
	UserID            string `json:"userID"`
	AccountID         string `json:"accountId"`
	ProfileURL        string `json:"profileUrl"`
	Email             string `json:"email"`
	HasPassword       byte   `json:"hasPassword"`
	LoginName         string `json:"loginName"`
	FullName          string `json:"fullName"`
	Gender            string `json:"gender"`
	Birthday          string `json:"birthday"`
	About             string `json:"about"`
	Website           string `json:"website"`
	Lang              string `json:"lang"`
	Location          string `json:"location"`
	ProfileColor      string `json:"profileColor"`
	IsFollowing       byte   `json:"isFollowing"`
	SafeMode          byte   `json:"safeMode"`
	HideUpvote        string `json:"hideUpvote"`
	TimezoneGMTOffset int    `json:"timezoneGmtOffset"`
	AvatarURLLarge    string `json:"avatarUrlLarge"`
	AvatarURLMedium   string `json:"avatarUrlMedium"`
	AvatarURLSmall    string `json:"avatarUrlSmall"`
	AvatarURLTiny     string `json:"avatarUrlTiny"`
	CanPostToFB       byte   `json:"canPostToFB"`
	FBDisplayName     string `json:"fbDisplayName"`
	FBUserID          string `json:"fbUserId"`
	FBTimeline        byte   `json:"fbTimeline"`
	FBPublish         byte   `json:"fbPublish"`
	FBLikeAction      byte   `json:"fbLikeAction"`
	FBCreateAction    byte   `json:"fbCreateAction"`
	FBCommentAction   byte   `json:"fbCommentAction"`
	GPlusAccountName  string `json:"gplusAccountName"`
	GPlusUserID       string `json:"gplusUserId"`
}

UserData describes user from LoginData

Jump to

Keyboard shortcuts

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