facebook

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

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

Go to latest
Published: Dec 21, 2018 License: GPL-3.0 Imports: 12 Imported by: 0

README

Facebook

GoDoc

A facebook API package that uses fasthttp to reduce memory allocation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Message        string `json:"message"`
	Type           string `json:"type"`
	Code           int    `json:"code"`
	ErrorSubcode   int    `json:"error_subcode"`
	IsTransient    bool   `json:"is_transient"`
	ErrorUserTitle string `json:"error_user_title"`
	ErrorUserMsg   string `json:"error_user_msg"`
	FBTraceID      string `json:"fbtrace_id"`
}

APIError is a facebook API error

func (*APIError) Error

func (a *APIError) Error() string

type Account

type Account struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	AccessToken string `json:"access_token"`
	Picture     string `json:"picture"`
}

Account is a user/page account

func (*Account) UnmarshalJSON

func (a *Account) UnmarshalJSON(b []byte) error

UnmarshalJSON override

type AdAccount

type AdAccount struct {
	ID        string `json:"id"`
	AccountID string `json:"account_id"`
}

AdAccount is the user Ad Account

func (*AdAccount) UnmarshalJSON

func (a *AdAccount) UnmarshalJSON(b []byte) error

UnmarshalJSON override

type Album

type Album struct {
	ID      string
	Name    string
	Message string
	Images  []Image
}

Album is a Facebook Album

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Facebook API client

func New

func New(token, version string) *Client

New retuns a new Client with the specified Auth Token

func (*Client) Album

func (c *Client) Album(albumID string) (*Album, error)

Album returns a Album

func (*Client) Albums

func (c *Client) Albums(userID string) ([]Album, error)

Albums returns a Albums

func (*Client) CreateAlbum

func (c *Client) CreateAlbum(userID string, a *Album, p Privacy) error

CreateAlbum creates a new Album

func (*Client) Execute

func (c *Client) Execute(method, path string, params map[string]interface{}, r interface{}, u ...Upload) error

Execute is the general method to call the API with the selected method/path. Response is unmarshalled inside r (that must be a pointer)

func (*Client) IsTemp

func (c *Client) IsTemp(err error) bool

IsTemp returns if an error is temporary

func (*Client) UploadVideo

func (c *Client) UploadVideo(u *UploadSession) error

UploadVideo creates a new upload session

func (*Client) UserProfile

func (c *Client) UserProfile(userID string) (*UserProfile, error)

UserProfile returns a UserProfile

type Image

type Image struct {
	ID     string
	Images []struct {
		Width  int
		Height int
		Source string
	}
}

Image is a Facebook Image

type Privacy

type Privacy string

Privacy is the element privacy level

const (
	// PrivacyPrivate is just visible to the user
	PrivacyPrivate Privacy = "SELF"
	// PrivacyFriends is visible to all user friends
	PrivacyFriends Privacy = "ALL_FRIENDS"
)

type Upload

type Upload struct {
	Name     string
	FileName string
	Data     io.ReadSeeker
	From, To int64
}

Upload is a chunked upload request

type UploadSession

type UploadSession struct {
	AdAccount string `json:"-"`
	Path      string `json:"-"`
	Size      int64  `json:"-"`

	Success *bool  `json:"success"`
	Title   string `json:"title"`
	Descr   string `json:"description"`

	UploadSessionID string `json:"upload_session_id"`
	VideoID         string `json:"video_id"`
	StartOffset     int64  `json:"start_offset"`
	EndOffset       int64  `json:"end_offset"`
}

UploadSession is the start of a Download

func (*UploadSession) Progress

func (u *UploadSession) Progress() float64

Progress returns a value between 0 and 1

func (*UploadSession) UnmarshalJSON

func (u *UploadSession) UnmarshalJSON(b []byte) error

UnmarshalJSON override

type UserProfile

type UserProfile struct {
	ID         string      `json:"id"`
	FirstName  string      `json:"first_name"`
	LastName   string      `json:"last_name"`
	Email      string      `json:"email"`
	Picture    string      `json:"picture"`
	Accounts   []Account   `json:"accounts"`
	AdAccounts []AdAccount `json:"adaccounts"`
}

UserProfile is Facebook user profile

func (*UserProfile) UnmarshalJSON

func (u *UserProfile) UnmarshalJSON(b []byte) error

UnmarshalJSON override

Jump to

Keyboard shortcuts

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