Documentation
¶
Index ¶
- Constants
- func ClassifyError(err error) int
- func DollarsToCents(d float64) (int64, error)
- type Ad
- type AdAccount
- type AdCreative
- type AdSet
- type AuthApp
- type AuthStatusResult
- type AuthUser
- type Campaign
- type Client
- type CreateAdParams
- type CreateAdSetParams
- type CreateCampaignParams
- type CreateCreativeParams
- type Creative
- type GraphError
- type ListAccountsParams
- type ListAccountsResult
- type ListPagesParams
- type ListPagesResult
- type Page
- type PageIterator
- type Response
- type SearchTargetingParams
- type SearchTargetingResult
- type TargetingSuggestion
- type UploadVideoParams
- type Video
- type VideoStatus
- type VideoStatusParams
Constants ¶
const ( ExitSuccess = 0 ExitAPIError = 1 ExitAuthError = 2 ExitValidationError = 3 ExitConfigError = 4 ExitNetworkError = 5 )
Variables ¶
This section is empty.
Functions ¶
func ClassifyError ¶
func DollarsToCents ¶
Types ¶
type Ad ¶
type Ad struct {
ID string `json:"id"`
Name string `json:"name"`
AdSetID string `json:"adset_id"`
Creative AdCreative `json:"creative"`
Status string `json:"status"`
}
Ad represents a Meta ad returned by the API.
type AdAccount ¶
type AdAccount struct {
ID string `json:"id"`
AccountID string `json:"account_id"`
Name string `json:"name"`
AccountStatus int `json:"account_status"`
Currency string `json:"currency"`
TimezoneName string `json:"timezone_name"`
AmountSpent string `json:"amount_spent"`
Balance string `json:"balance"`
}
AdAccount represents a Meta ad account.
type AdCreative ¶
type AdCreative struct {
ID string `json:"id"`
}
AdCreative holds the creative reference within an ad.
type AdSet ¶
type AdSet struct {
ID string `json:"id"`
Name string `json:"name"`
CampaignID string `json:"campaign_id"`
Status string `json:"status"`
DailyBudget string `json:"daily_budget,omitempty"`
LifetimeBudget string `json:"lifetime_budget,omitempty"`
}
AdSet represents a Meta ad set returned by the API.
func CreateAdSet ¶
CreateAdSet creates a new ad set under the given ad account.
type AuthStatusResult ¶
type AuthStatusResult struct {
Valid bool `json:"valid"`
User AuthUser `json:"user"`
App AuthApp `json:"app"`
Permissions []string `json:"permissions"`
ExpiresAt string `json:"expires_at"`
Scopes []string `json:"scopes"`
}
AuthStatusResult contains the result of validating an access token.
func AuthStatus ¶
func AuthStatus(ctx context.Context, client Client) (*AuthStatusResult, error)
AuthStatus validates the current access token by calling /me, /me/permissions, and /debug_token to populate the full AuthStatusResult including app identity and token expiry. The client's token is used implicitly (injected by the transport layer).
type Campaign ¶
type Campaign struct {
ID string `json:"id"`
Name string `json:"name"`
Objective string `json:"objective"`
Status string `json:"status"`
DailyBudget string `json:"daily_budget,omitempty"`
LifetimeBudget string `json:"lifetime_budget,omitempty"`
}
Campaign represents a Meta campaign returned by the API.
func CreateCampaign ¶
func CreateCampaign(ctx context.Context, client Client, params CreateCampaignParams) (*Campaign, error)
CreateCampaign creates a new campaign under the given ad account.
type Client ¶
type Client interface {
Get(ctx context.Context, path string, params url.Values) (*Response, error)
Post(ctx context.Context, path string, params map[string]string) (*Response, error)
Upload(ctx context.Context, path string, file io.Reader, filename string, size int64, params map[string]string) (*Response, error)
Paginate(ctx context.Context, path string, params url.Values) *PageIterator
SetDryRun(v bool)
SetVerbose(v bool)
}
type CreateAdParams ¶
type CreateAdParams struct {
AccountID string
Name string
AdSetID string
CreativeID string
Status string // default: PAUSED
}
CreateAdParams holds the input for creating a Meta ad.
type CreateAdSetParams ¶
type CreateAdSetParams struct {
AccountID string
Name string
CampaignID string
DailyBudgetCents int64
LifetimeBudgetCents int64
OptimizationGoal string
BillingEvent string // default: IMPRESSIONS
BidAmountCents int64
Countries []string // required, non-empty
AgeMin int // default: 18
AgeMax int // default: 65
Genders []int // default: [1,2]
Interests []string // interest IDs
Behaviors []string
CustomAudiences []string
ExcludedCountries []string
PublisherPlatforms []string
PixelID string
CustomEventType string
StartTime string
EndTime string
AdvantageAudience bool // default: false (explicit targeting)
Status string // default: PAUSED
}
CreateAdSetParams holds the input for creating a Meta ad set.
type CreateCampaignParams ¶
type CreateCampaignParams struct {
AccountID string
Name string
Objective string // OUTCOME_SALES, OUTCOME_TRAFFIC, etc.
DailyBudgetCents int64 // mutually exclusive with LifetimeBudgetCents
LifetimeBudgetCents int64
BidStrategy string // default: LOWEST_COST_WITHOUT_CAP
Status string // default: PAUSED
SpecialAdCategory string // default: NONE
}
CreateCampaignParams holds the input for creating a Meta campaign.
type CreateCreativeParams ¶
type CreateCreativeParams struct {
AccountID string
Name string
PageID string // required
VideoID string // one of VideoID/ImageHash/ImageURL required
ImageHash string
ImageURL string
Message string // required
Headline string
Description string
CTA string // default: SHOP_NOW
Link string // required
InstagramAccountID string
}
CreateCreativeParams holds the input for creating a Meta ad creative.
type Creative ¶
Creative represents a Meta ad creative returned by the API.
func CreateCreative ¶
func CreateCreative(ctx context.Context, client Client, params CreateCreativeParams) (*Creative, error)
CreateCreative creates a new ad creative under the given ad account.
type GraphError ¶
type GraphError struct {
Message string `json:"message"`
Type string `json:"type"`
Code int `json:"code"`
Subcode int `json:"error_subcode"`
TraceID string `json:"fbtrace_id"`
IsRetryable bool
}
func ParseGraphError ¶
func ParseGraphError(body []byte) *GraphError
func (*GraphError) Error ¶
func (e *GraphError) Error() string
type ListAccountsParams ¶
type ListAccountsParams struct {
Limit int
}
ListAccountsParams configures the ad accounts listing request.
type ListAccountsResult ¶
type ListAccountsResult struct {
Data []AdAccount `json:"data"`
HasNext bool `json:"has_next"`
Cursor string `json:"cursor"`
}
ListAccountsResult contains ad accounts and pagination state.
func ListAccounts ¶
func ListAccounts(ctx context.Context, client Client, params ListAccountsParams) (*ListAccountsResult, error)
ListAccounts retrieves ad accounts accessible by the authenticated user. GET /me/adaccounts?fields=account_id,name,account_status,currency,timezone_name,amount_spent,balance&limit=N
type ListPagesParams ¶
type ListPagesParams struct {
Limit int
}
ListPagesParams configures the pages listing request.
type ListPagesResult ¶
type ListPagesResult struct {
Data []Page `json:"data"`
HasNext bool `json:"has_next"`
Cursor string `json:"cursor"`
}
ListPagesResult contains pages and pagination state.
func ListPages ¶
func ListPages(ctx context.Context, client Client, params ListPagesParams) (*ListPagesResult, error)
ListPages retrieves Facebook Pages the authenticated user manages. GET /me/accounts?fields=id,name,category,access_token&limit=N
type Page ¶
type Page struct {
ID string `json:"id"`
Name string `json:"name"`
Category string `json:"category"`
AccessToken string `json:"access_token"`
}
Page represents a Facebook Page managed by the authenticated user.
type PageIterator ¶
type PageIterator struct {
// contains filtered or unexported fields
}
func NewPageIterator ¶
func NewPageIterator(client Client, path string, params url.Values) *PageIterator
func (*PageIterator) Err ¶
func (it *PageIterator) Err() error
func (*PageIterator) Page ¶
func (it *PageIterator) Page() (*Response, error)
type SearchTargetingParams ¶
SearchTargetingParams contains the parameters for searching targeting options.
type SearchTargetingResult ¶
type SearchTargetingResult struct {
Data []TargetingSuggestion `json:"data"`
}
SearchTargetingResult contains the list of targeting suggestions from the API.
func SearchTargeting ¶
func SearchTargeting(ctx context.Context, client Client, params SearchTargetingParams) (*SearchTargetingResult, error)
SearchTargeting searches for targeting options (interests, behaviors, demographics, etc.).
type TargetingSuggestion ¶
type TargetingSuggestion struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
AudienceSizeLowerBound int64 `json:"audience_size_lower_bound"`
AudienceSizeUpperBound int64 `json:"audience_size_upper_bound"`
Path []string `json:"path"`
}
TargetingSuggestion represents a single targeting option returned by the API.
type UploadVideoParams ¶
type UploadVideoParams struct {
AccountID string
File io.Reader
Filename string
FileSize int64
Title string
}
UploadVideoParams contains the parameters for uploading a video to an ad account.
type Video ¶ added in v0.1.1
type Video struct {
ID string `json:"id"`
Title string `json:"title"`
Status VideoStatus `json:"status"`
Length float64 `json:"length"`
}
Video is the canonical representation of a Meta video resource, shared by UploadVideo and GetVideoStatus. It is the single source of truth for the shape of a video returned to callers.
func GetVideoStatus ¶
GetVideoStatus fetches the current metadata and encoding status of a video.
func UploadVideo ¶
UploadVideo uploads a video file to the specified ad account and returns the full video record (id, title, status, length). Because Meta's upload endpoint only returns the new video's id, this function issues a follow-up GET against the same path used by GetVideoStatus so callers always receive a fully populated Video regardless of which code path produced it.
type VideoStatus ¶
type VideoStatus struct {
VideoStatus string `json:"video_status"`
ProcessingProgress int `json:"processing_progress"`
}
VideoStatus represents the encoding status of a video.
type VideoStatusParams ¶
type VideoStatusParams struct {
VideoID string
}
VideoStatusParams contains the parameters for checking video encoding status.