Documentation
¶
Overview ¶
Package ajaxapi handles the AJAX functionality which is not usable from neither the public or the mobile API such as the fanboxes or possibly the like functionality
Index ¶
- Constants
- type APIError
- type APIRequestError
- type AjaxAPI
- func (a *AjaxAPI) AddRoundTrippers()
- func (a *AjaxAPI) GetCreator(userID int) (*CreatorInfo, error)
- func (a *AjaxAPI) GetPostInfo(postID int) (*FanboxPostInfo, error)
- func (a *AjaxAPI) GetPostList(userID int, limit int) (*PostInfo, error)
- func (a *AjaxAPI) GetPostListByURL(url string) (*PostInfo, error)
- type CreatorInfo
- type FanboxPost
- type FanboxPostInfo
- type FanboxUser
- type PostInfo
Constants ¶
const CookieSession = "PHPSESSID"
CookieSession is the session cookie which is set after a successful login
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIRequestError ¶
type APIRequestError struct {
ErrorMessage string `json:"error"`
}
APIRequestError is the error struct of invalid requests
func (APIRequestError) Error ¶
func (e APIRequestError) Error() string
Error returns the occurred API error message
type AjaxAPI ¶
type AjaxAPI struct {
StorageURL *url.URL
Session watcherHttp.SessionInterface
Key string
SessionCookie *models.Cookie
}
AjaxAPI is the implementation of the not reachable but required endpoints not in the public or mobile API
func NewAjaxAPI ¶
NewAjaxAPI initializes the AJAX API and handles the whole auth and round tripper procedures
func (*AjaxAPI) AddRoundTrippers ¶
func (a *AjaxAPI) AddRoundTrippers()
AddRoundTrippers sets the required pixiv session sessionCookie required for the AJAX API and adds the round trippers to the session client
func (*AjaxAPI) GetCreator ¶
func (a *AjaxAPI) GetCreator(userID int) (*CreatorInfo, error)
GetCreator requests the creator information from the unofficial ajax/fanbox/creator endpoint
func (*AjaxAPI) GetPostInfo ¶
func (a *AjaxAPI) GetPostInfo(postID int) (*FanboxPostInfo, error)
GetPostInfo requests the fanbox post info from the API for the passed post ID
func (*AjaxAPI) GetPostList ¶
GetPostList returns the initial post list of the passed user
type CreatorInfo ¶
type CreatorInfo struct {
Body struct {
Creator struct {
User FanboxUser `json:"user"`
Description string `json:"description"`
} `json:"creator"`
Post struct {
Items []FanboxPost `json:"items"`
NextURL string `json:"nextUrl"`
} `json:"post"`
} `json:"body"`
Error bool `json:"error"`
Message string `json:"message"`
}
CreatorInfo contains all relevant information on the creator
type FanboxPost ¶
type FanboxPost struct {
ID json.Number `json:"id"`
Title string `json:"title"`
Type string `json:"type"`
User FanboxUser `json:"user"`
}
FanboxPost contains the relevant information on posts in the fanbox
type FanboxPostInfo ¶
type FanboxPostInfo struct {
Body struct {
PostBody struct {
Text string `json:"text"`
Files []*struct {
ID string `json:"id"`
Name string `json:"name"`
Extension string `json:"extension"`
URL string `json:"url"`
}
Images []*struct {
ID string `json:"id"`
Extension string `json:"extension"`
OriginalURL string `json:"originalUrl"`
ThumbnailURL string `json:"thumbnailUrl"`
} `json:"images"`
Blocks []struct {
Type string `json:"type"`
Text string `json:"text"`
ImageID string `json:"imageId"`
} `json:"blocks"`
ImageMap map[string]struct {
ID string `json:"id"`
OriginalURL string `json:"originalUrl"`
} `json:"imageMap"`
} `json:"body"`
ID json.Number `json:"id"`
Title string `json:"title"`
ImageForShare string `json:"imageForShare"`
} `json:"body"`
}
FanboxPostInfo contains the relevant fanbox post information
func (*FanboxPostInfo) ImagesFromBlocks ¶
func (i *FanboxPostInfo) ImagesFromBlocks() []string
ImagesFromBlocks returns all image URLs from the Blocks section of the fanbox post
type FanboxUser ¶
FanboxUser contains the relevant information of the user passed from the API
func (*FanboxUser) GetUserTag ¶
func (u *FanboxUser) GetUserTag() string
GetUserTag returns the default download tag for illustrations of the user context
type PostInfo ¶
type PostInfo struct {
Body struct {
Items []FanboxPost `json:"items"`
NextURL string `json:"nextUrl"`
} `json:"body"`
}
PostInfo contains all relevant pixiv fanbox post info