v24

package
v0.0.0-...-452956c Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OPT_OUT = "OPT_OUT"
	OPT_IN  = "OPT_IN"
)
View Source
const BatchMaxIDsSequence = 10000

BatchMaxIDsSequence we upload.

View Source
const Version = "v24.0"

Version of the graph API being used.

Variables

View Source
var Adcreativefields = []string{
	"id",
	"account_id",
	"body",
	"call_to_action_type",
	"call_to_action",
	"destination_spec",
	"effective_instagram_media_id",
	"effective_object_story_id",
	"image_hash",
	"image_url",
	"instagram_user_id",
	"instagram_permalink_url",
	"source_instagram_media_id",
	"link_og_id",
	"link_url",
	"name",
	"interactive_components_spec",
	"object_id",
	"object_story_id",
	"object_story_spec",
	"object_type",
	"object_url",
	"status",
	"thumbnail_url",
	"title",
	"video_id",
	"asset_feed_spec",
}

Adcreativefields are the fields of an adcreative.

View Source
var AdsetFields = []string{
	"bid_amount", "attribution_spec", "bid_info",
	"billing_event", "campaign_id", "created_time",
	"daily_budget", "destination_type", "effective_status",
	"daily_spend_cap", "daily_min_spend_target", "end_time",
	"creative_sequence", "frequency_control_specs", "id",
	"configured_status", "instagram_user_id", "lifetime_budget",
	"lifetime_imps", "lifetime_min_spend_target", "lifetime_spend_cap",
	"name", "budget_remaining", "optimization_goal", "adset_schedule",
	"adlabels", "recurring_budget_semantics",
	"rf_prediction_id", "source_adset_id", "start_time", "targeting",
	"time_based_ad_rotation_id_blocks", "time_based_ad_rotation_intervals",
	"pacing_type", "placement_soft_opt_out", "promoted_object", "recommendations",
	"source_adset", "status", "updated_time", "use_new_app_click",
	"campaign{name,objective,effective_status}", "dsa_beneficiary", "dsa_payor",
}

AdsetFields is a selection of fields to be returned.

DefaultEffectiveStatuses is the default set of effective_status values returned by the CampaignService.List call.

Functions

This section is empty.

Types

type ActionTypeValue

type ActionTypeValue []struct {
	ActionType       string  `json:"action_type"`
	ActionVideoSound string  `json:"action_video_sound"`
	ActionReaction   string  `json:"action_reaction"`
	Value            float64 `json:"value,string"`

	// For action_attribution_windows
	View1d   float64 `json:"1d_view,string"`
	View7d   float64 `json:"7d_view,string"`
	View28d  float64 `json:"28d_view,string"`
	Click1d  float64 `json:"1d_click,string"`
	Click7d  float64 `json:"7d_click,string"`
	Click28d float64 `json:"28d_click,string"`
}

ActionTypeValue is a kv store.

func (ActionTypeValue) FilterByActionTypePrefix

func (atv ActionTypeValue) FilterByActionTypePrefix(prefix string) ActionTypeValue

FilterByActionTypePrefix returns a slice of ActionTypeValue for which all ActionType values starts with the input prefix.

func (ActionTypeValue) GetCustomConversion

func (atv ActionTypeValue) GetCustomConversion() float64

GetCustomConversion returns the custom conversions of the values with the given action type.

func (ActionTypeValue) GetReactions

func (atv ActionTypeValue) GetReactions() map[string]uint64

GetReactions returns a map with reactions.

func (ActionTypeValue) GetValue

func (atv ActionTypeValue) GetValue(actionType string) float64

GetValue returns the sum of the values with the given action type.

type Ad struct {
	AccountID     string                  `json:"account_id,omitempty"`
	ID            string                  `json:"id,omitempty"`
	Name          string                  `json:"name,omitempty"`
	Status        string                  `json:"status,omitempty"`
	AdsetID       string                  `json:"adset_id,omitempty"`
	Creative      *AdCreative             `json:"creative,omitempty"`
	Adset         *Adset                  `json:"adset,omitempty"`
	TrackingSpecs []ConversionActionQuery `json:"tracking_specs,omitempty"`
	Adcreatives   *struct {
		Data []AdCreative `json:"data,omitempty"`
	} `json:"adcreatives,omitempty"`
}

Ad represents a Facebook Ad.

type AdAccount

type AdAccount struct {
	Name         string `json:"name"`
	AccountID    string `json:"account_id"`
	Currency     string `json:"currency"`
	TimeZoneName string `json:"timezone_name"`
}

AdAccount represents an ad account.

type AdAccountService

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

AdAccountService works with ad accounts.

func (*AdAccountService) List

func (aas *AdAccountService) List(ctx context.Context, businessID string) ([]AdAccount, error)

List lists all ad accounts that belong to this business.

func (*AdAccountService) ValidateTargeting

func (aas *AdAccountService) ValidateTargeting(ctx context.Context, adAccountID string, ids []string) (validIDs, invalidIDs []string, err error)

ValidateTargeting validates a list of targeting IDs against the ad account's targetingvalidation endpoint. Returns the IDs that are valid and those that are invalid.

type AdCreative

type AdCreative struct {
	ID         string `json:"id,omitempty"`
	CreativeID string `json:"creative_id,omitempty"`
	AccountID  string `json:"account_id,omitempty"`
	// PageID
	ActorID string `json:"actor_id,omitempty"`
	// Deep link fallback behavior for dynamic product ads if the app is not installed.
	ApplinkTreatment string `json:"applink_treatment,omitempty"`
	// The body of the ad. Not supported for video post creatives.
	Body string `json:"body,omitempty"`
	// Branded Content sponsor ID, creating ads using existing BC posts
	BrandedContentSponsorPageID string `json:"branded_content_sponsor_page_id,omitempty"`

	CallToActionType string `json:"call_to_action_type,omitempty"`
	// The ID of an Instagram post to use in an ad.
	EffectiveInstagramStoryID string `json:"effective_instagram_media_id,omitempty"`
	// The ID of a page post to use in an ad, regardless of whether it's an organic or unpublished page post.
	EffectiveObjectStoryID string `json:"effective_object_story_id,omitempty"`
	// Image hash for an image you can use in creatives. If provided do not provide image_url. See image library for more details
	ImageHash string `json:"image_hash,omitempty"`
	// A URL for the image for this creative. We save the image at this URL to the ad account's image library. If provided do not include image_hash.
	ImageURL string `json:"image_url,omitempty"`
	// IG User ID
	InstagramUserID string `json:"instagram_user_id,omitempty"`
	// The ID of an Instagram media object for creating ads.
	SourceInstagramMediaID string `json:"source_instagram_media_id,omitempty"`
	// CallToAction
	CallToAction *AdCreativeLinkDataCallToAction `json:"call_to_action,omitempty"`
	// Instagram permalink
	InstagramPermalinkURL string `json:"instagram_permalink_url,omitempty"`
	// Used for creating video polls
	InteractiveComponentsSpec *InteractiveComponentsSpec `json:"interactive_components_spec,omitempty"`
	// The Open Graph (OG) ID for the link in this creative if the landing page has OG tags
	LinkOgID string `json:"link_og_id,omitempty"`
	// Used to identify a specific landing tab on the Page (e.g. a Page tab app)
	// by the Page tab's URL. See connection objects for retrieving Page tabs' URLs.
	// The likes tab is not supported. app_data parameters may be added to the url to pass data to a tab app
	LinkURL string `json:"link_url,omitempty"`
	// The JSON string of messenger sponsored message for this creative. See (docs/messenger-platform/reference/send-api) for more detail
	MessengerSponsoredMessage string `json:"messenger_sponsored_message,omitempty"`
	// The name of the creative in the creative library.
	Name string `json:"name,omitempty"`
	// The ID of the promoted_object or object that is relevant to the ad and ad type
	ObjectID string `json:"object_id,omitempty"`
	// The ID of a page post to use in an ad. This ID can be retrieved by using
	// the graph API to query the posts of the page. If an image is used in the post,
	// it will be downloaded and available in your account's image library.
	// If you create an unpublished page post inline via object_story_spec at
	// the same time as creating the ad, this ID will be null. However the
	// effective_object_story_id will be the ID of the page post regardless of whether it's an organic or unpublished page post.
	ObjectStoryID string `json:"object_story_id,omitempty"`
	// The type of object that is being advertised.
	// PAGE, DOMAIN, EVENT, STORE_ITEM, SHARE, PHOTO, STATUS, VIDEO, APPLICATION, INVALID
	ObjectType string `json:"object_type,omitempty"`
	// Destination URL for a link ads not connected to a page
	ObjectURL string `json:"object_url,omitempty"`
	// The ID of the product set for this creative. See dynamic product ads for more detail
	ProductSetID string `json:"product_set_id,omitempty"`
	// The status of this creative.
	Status string `json:"status,omitempty"`
	// The Tracking URL for dynamic product ads. See dynamic product ads for more detail
	TemplateURL string `json:"template_url,omitempty"`
	// The URL to a thumbnail for this creative.
	ThumbnailURL string `json:"thumbnail_url,omitempty"`
	// Title for a link ad (not connected to a Page)
	Title string `json:"title,omitempty"`
	// A set of query string parameters which will replace or be appended to urls
	// clicked from page post ads, message of the post, and canvas app install creatives only
	URLTags string `json:"url_tags,omitempty"`
	// The ID of the video in this creative
	VideoID string `json:"video_id,omitempty"`
	// If this is true, we will show the page actor for mobile app ads
	UsePageActorOverride bool `json:"use_page_actor_override,omitempty"`
	// A JSON object defining crop dimensions for the image specified. See image crop reference for more details
	ImageCrops json.RawMessage `json:"image_crops,omitempty"`
	// The page id and the content to create a new unpublished page post specified using one of link_data, photo_data, video_data, text_data or template_data
	ObjectStorySpec *ObjectStorySpec `json:"object_story_spec,omitempty"`
	// Use this field to customize the media for different Facebook placements.
	// Currently you can use this field for customizing images only. The media
	// specified here replaces the original media defined in the ad creative when
	// the ad displays on those placements. For example, if you define a media
	// here for the instagram key, Facebook uses that media instead of the media
	// defined in the ad creative when showing the ad on Instagram.
	PlatformCustomizations json.RawMessage `json:"platform_customizations,omitempty"`
	// The recommender settings that can be used to control recommendations for Dynamic Ads.
	RecommenderSettings json.RawMessage `json:"recommender_settings,omitempty"`
	// Use this field to create url templates for dynamic product ads. See dynamic product ads for more detail
	TemplateURLSpec json.RawMessage `json:"template_url_spec,omitempty"`
	// Ad Labels that are associated with this creative
	Adlabels []json.RawMessage `json:"adlabels,omitempty"`
	// DegreesOfFreedomSpec Specifies the types of transformations that are enabled for the given creative. For more information, see Ad Creative Degrees Of Freedom Spec, Reference.
	DegreesOfFreedomSpec *DegreesOfFreedomSpec `json:"degrees_of_freedom_spec,omitempty"`
	// ContextualMultiAds controls whether the ad can appear in multi-advertiser ad units.
	// See https://developers.facebook.com/docs/marketing-api/creative/multi-advertiser-ads/
	ContextualMultiAds *EnrollStatus `json:"contextual_multi_ads,omitempty"`
	// AssetFeedSpec for dynamic creative or placement-specific asset customization
	AssetFeedSpec *AssetFeedSpec `json:"asset_feed_spec,omitempty"`
	// DestinationSpec for website destination optimization (v24.0+)
	DestinationSpec json.RawMessage `json:"destination_spec,omitempty"`
}

AdCreative https://developers.facebook.com/docs/marketing-api/reference/ad-creative

func (AdCreative) GetLandingPageURL

func (ac AdCreative) GetLandingPageURL() string

GetLandingPageURL returns the landing page URL of the creative.

func (AdCreative) GetLinkCaption

func (ac AdCreative) GetLinkCaption() string

GetLinkCaption returns the link caption page URL of the creative.

type AdCreativeLinkData

type AdCreativeLinkData struct {
	// The index (zero based) of the image from the additional images array to use as the ad image for a dynamic product ad
	AdditionalImageIndex int32 `json:"additional_image_index,omitempty"`
	// Native deeplinks attached to the post
	AppLinkSpec *AdCreativeLinkDataAppLinkSpec `json:"app_link_spec,omitempty"`
	// The style of the attachment
	AttachmentStyle string `json:"attachment_style,omitempty"`
	// The branded content shared to sponsor option
	BrandedContentSharedToSponsorStatus string `json:"branded_content_shared_to_sponsor_status,omitempty"`
	// The branded content sponsor page id
	BrandedContentSponsorPageID string `json:"branded_content_sponsor_page_id,omitempty"`
	// The branded content sponsor relationship option
	BrandedContentSponsorRelationship string `json:"branded_content_sponsor_relationship,omitempty"`
	// An optional call to action button. If not specified, on Instagram, a default CTA would be used, {"type":"LEARN_MORE","value": {"link":<LINK VALUE OF LINK_DATA>,}}. Note that LIKE_PAGE is not supported
	CallToAction *AdCreativeLinkDataCallToAction `json:"call_to_action,omitempty"`
	// Link caption. Overwrites the caption under the title in the link. The caption must be an actual URLs and should accurately reflect the URL and associated advertiser or business someone visits when they click on it. See post for more info. This setting is not used on Instagram
	Caption string `json:"caption,omitempty"`
	// A 2-5 element array of link objects required for carousel ads. If multi_share_optimized is set to true, this array could have up to 10 objects. Facebook will automatically optimize the order in which the carousel cards are shown and display the top 5. We strongly recommend that you use at least 3 attachments for achieving optimal performance; allowing minimum of 2 attachments is for enabling lightweight integrations and using 2 objects might result in sub-optimal campaign results. If this ad creative is used for an Instagram Carousel ad, you will need to have at least 3 attachments for MOBILE_APP_INSTALLS ads and 2 for the other objectives. If more than 5 are given, only the first 5 will be shown on Instagram, even if multi_share_optimized is true.
	ChildAttachments []AdCreativeLinkDataChildAttachment `json:"child_attachments,omitempty"`
	// Customization rules for a dynamic ad
	// CustomizationRulesSpec []AdCustomizationRuleSpec `json:"customization_rules_spec,omitempty"`
	// Link description. Overwrites the description in the link on Facebook. See post for more info. This setting is not used on Instagram
	Description string `json:"description,omitempty"`
	// The id of a Facebook event. This is only to be used if this creative is for a Website Clicks campaign, the Call To Action is Buy Tickets, and the link points to the ticketing website of this Facebook event
	EventID string `json:"event_id,omitempty"`
	// Whether to force the post to render in a single link format
	ForceSingleLink bool `json:"force_single_link,omitempty"`
	// How to the image should be cropped. Different placements use different crop specs. For example, Facebook News Feed uses the crop spec with 191x100 key, and Instagram uses 100x100 crop spec
	// ImageCrops *AdsImageCrops `json:"image_crops,omitempty"`
	// Hash of an image in your image library with Facebook. Specify this field or picture but not both
	ImageHash string `json:"image_hash,omitempty"`
	// How to render image overlays on a dynamic item in Dynamic Ads
	// ImageOverlaySpec *AdCreativeLinkDataImageOverlaySpec `json:"image_overlay_spec,omitempty"`
	// Link url. This url is required to be the same as the CTA link url. See post for more info. This field is required for a carousel ad
	Link string `json:"link,omitempty"`
	// The main body of the post. See post for more info. This field is required for a carousel ad
	Message string `json:"message,omitempty"`
	// If set to false, removes the end card which displays the page icon. Default is true. Used by carousel ads
	MultiShareEndCard bool `json:"multi_share_end_card,omitempty"`
	// If set to true, automatically select and order images and links. Default is true. Used by carousel ads
	MultiShareOptimized bool `json:"multi_share_optimized,omitempty"`
	// Name of the link. Overwrites the title of the link preview. See post for more info
	Name string `json:"name,omitempty"`
	// The id of a Facebook native offer
	OfferID string `json:"offer_id,omitempty"`
	// A welcome text from page to user on Messenger once a user performs send message action on an ad
	PageWelcomeMessage string `json:"page_welcome_message,omitempty"`
	// URL of a picture to use in the post. Specify this field or image_hash but not both. See post for more info. The image specified at the URL will be saved into the ad accounts image library
	Picture string `json:"picture,omitempty"`
	// Customized contents provided by the advertiser for the ad post-click experience
	// PostClickConfiguration AdCreativePostClickConfiguration `json:"post_click_configuration,omitempty"`
	// List of product IDs provided by the advertiser for Collections
	RetailerItemIDs []string `json:"retailer_item_ids,omitempty"`
	// Use with force_single_link = true in order to show a single dynamic item but in carousel format using multiple images from the catalog. See dynamic product ad
	ShowMultipleImages bool `json:"show_multiple_images,omitempty"`
}

AdCreativeLinkData see https://developers.facebook.com/docs/marketing-api/reference/ad-creative-link-data/

type AdCreativeLinkDataAppLinkSpec

type AdCreativeLinkDataAppLinkSpec struct {
	// Native deeplinks to use on Android
	Android []AndroidAppLink `json:"android,omitempty"`
	// Native deeplinks to use on iOS
	Ios []IosAppLink `json:"ios,omitempty"`
	// Native deeplinks to use on iPad
	Ipad []IosAppLink `json:"ipad,omitempty"`
	// Native deeplinks to use on iPhone
	Iphone []IosAppLink `json:"iphone,omitempty"`
}

AdCreativeLinkDataAppLinkSpec see https://developers.facebook.com/docs/marketing-api/reference/ad-creative-link-data-app-link-spec/

type AdCreativeLinkDataCallToAction

type AdCreativeLinkDataCallToAction struct {
	// The type of the action. Not all types can be used for all ads. Check Ads Product Guide to see which type can be used based on the objective of your campaign.
	Type string `json:"type,omitempty"`
	// JSON containing the call to action data.
	Value *AdCreativeLinkDataCallToActionValue `json:"value,omitempty"`
}

AdCreativeLinkDataCallToAction see https://developers.facebook.com/docs/marketing-api/reference/ad-creative-link-data-call-to-action/

type AdCreativeLinkDataCallToActionValue

type AdCreativeLinkDataCallToActionValue struct {
	// The app destination type.
	AppDestination string `json:"app_destination,omitempty"`
	// Deep link to the app.
	AppLink string `json:"app_link,omitempty"`
	// Application related to the action.
	Application string `json:"application,omitempty"`
	// ID of the Facebook event which the attachement show event info
	EventID string `json:"event_id,omitempty"`
	// The Lead Ad form id.
	LeadGenFormID string `json:"lead_gen_form_id,omitempty"`
	// The destination link when the CTA button is clicked. This is required to be same as the link url of the creative.
	Link string `json:"link,omitempty"`
	// Caption shown in the attachment. The caption must be an actual URL and should accurately reflect the URL and associated advertiser or business someone visits when they click on it.
	LinkCaption string `json:"link_caption,omitempty"`
	// Link format of video.
	LinkFormat string `json:"link_format,omitempty"`
	// ID of the Facebook page which the CTA button links to
	Page string `json:"page,omitempty"`
	// Open graph object url for canvas virtual good ads.
	ProductLink string `json:"product_link,omitempty"`
}

AdCreativeLinkDataCallToActionValue see https://developers.facebook.com/docs/marketing-api/reference/ad-creative-link-data-call-to-action-value/

type AdCreativeLinkDataChildAttachment

type AdCreativeLinkDataChildAttachment struct {
	// Call to action of this attachment. On Facebook, we support one optional CTA per attachment. If it not specified, there will be no CTA for this attachment. On Instagram, there is one CTA per attachment. If the CTA is not specified, a CTA will be created by the system, using "Learn more" as the type, and the link from this child attachment as the link. If the CTA is specified, its link must be the same as the link of this child attachment.
	CallToAction *AdCreativeLinkDataCallToAction `json:"call_to_action,omitempty"`
	// The display url shown at the end of a video, if the attachment is a video
	Caption string `json:"caption,omitempty"`
	// Overwrites the description of each attachment on Facebook, not used on Instagram.
	Description string `json:"description,omitempty"`
	// Image crops, using the crop spec with 100x100 key for Carousel ads. If no 100x100 crop spec is provided, the image would be cropped automatically, unless the image is square already. The final cropped image size needs to be at least 200x200 pixels for Facebook, or 600x600 for Instagram.
	// ImageCrops *AdsImageCrops `json:"image_crops,omitempty"`
	// The image hash of an uploaded image for this attachment. For an ad on Facebook, if neither picture nor image_hash is set, the image of link_data above will be used. For an ad on Instagram, either picture or image_hash is required.
	ImageHash string `json:"image_hash,omitempty"`
	// The link of this attachment.
	Link string `json:"link,omitempty"`
	// Overwrites the title of the attachment on Facebook, not used on Instagram.
	Name string `json:"name,omitempty"`
	// The url of an image for this attachment. For an ad on Facebook, if neither picture nor image_hash is set, the image specified in link_data above will be used. For an ad on Instagram, either picture or image_hash is required.
	Picture string `json:"picture,omitempty"`
	// Whether to force the card to render statically, even in a dynamic ad.
	StaticCard bool `json:"static_card,omitempty"`
	// ID of an uploaded video, if this attachment is a video. Not supported for Instagram ads.
	VideoID string `json:"video_id,omitempty"`
}

AdCreativeLinkDataChildAttachment see https://developers.facebook.com/docs/marketing-api/reference/ad-creative-link-data-child-attachment/

type AdCreativeListCall

type AdCreativeListCall struct {
	*fb.RouteBuilder
	// contains filtered or unexported fields
}

func (*AdCreativeListCall) Do

Do calls the graph API.

func (*AdCreativeListCall) ReadList

func (s *AdCreativeListCall) ReadList(ctx context.Context, act string, res chan<- AdCreative) error

ReadList writes all adcreatives from an account to res.

type AdCreativePhotoData

type AdCreativePhotoData struct {
	BrandedContentSharedToSponsorStatus string `json:"branded_content_shared_to_sponsor_status"`
	BrandedContentSponsorPageID         string `json:"branded_content_sponsor_page_id"`
	BrandedContentSponsorRelationship   string `json:"branded_content_sponsor_relationship"`
	Caption                             string `json:"caption"`
	ImageHash                           string `json:"image_hash"`
	PageWelcomeMessage                  string `json:"page_welcome_message"`
	URL                                 string `json:"url"`
}

AdCreativePhotoData is the specific part of a creative that only photo posts do have.

type AdCreativeService

type AdCreativeService struct {
	*fb.StatsContainer
	// contains filtered or unexported fields
}

AdCreativeService works on adcreatives.

func (*AdCreativeService) Create

Create uploads a new adcreative and returns the ID.

func (*AdCreativeService) Get

func (as *AdCreativeService) Get(ctx context.Context, id string) (*AdCreative, error)

Get return a single creative.

func (*AdCreativeService) GetPreviewURL

func (as *AdCreativeService) GetPreviewURL(ctx context.Context, id, format string) (string, error)

GetPreviewURL returns the preview URL of a creative.

func (*AdCreativeService) List

func (s *AdCreativeService) List(act string, fields []string) *AdCreativeListCall

func (*AdCreativeService) ListOfCampaign

func (s *AdCreativeService) ListOfCampaign(campaignID string, fields []string) *AdCreativeListCall

type AdGeoLocation

type AdGeoLocation struct {
	Key            string `json:"key"`
	Name           string `json:"name"`
	Type           string `json:"type"`
	CountryCode    string `json:"country_code"`
	SupportsRegion bool   `json:"supports_region"`
	SupportsCity   bool   `json:"supports_city"`
}

AdGeoLocation contains different geolocation types to be used for adset targeting.

type AdListCall

type AdListCall struct {
	*fb.RouteBuilder
	// contains filtered or unexported fields
}

AdListCall is used for Listing ads.

func (*AdListCall) Do

func (as *AdListCall) Do(ctx context.Context) ([]Ad, error)

Do calls the graph API.

func (*AdListCall) Read

func (as *AdListCall) Read(ctx context.Context, c chan<- Ad) error

Do calls the graph API.

type AdLocale

type AdLocale struct {
	Key  int    `json:"key"`
	Name string `json:"name"`
}

AdLocale can be used for locale adset targeting.

type AdService

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

AdService works with Ads.

func (*AdService) Create

func (as *AdService) Create(ctx context.Context, a Ad) (string, error)

Create uploads a new ad, returns the fields and returns the created ad.

func (*AdService) Get

func (as *AdService) Get(ctx context.Context, id string) (*Ad, error)

Get returns a single ad.

func (*AdService) List

func (as *AdService) List(act string) *AdListCall

List returns all ads of an account.

func (*AdService) ListOfAdset

func (as *AdService) ListOfAdset(adsetID string) *AdListCall

ListOfAdset returns all ads of an adset.

func (*AdService) ListOfCampaign

func (as *AdService) ListOfCampaign(campaignID string) *AdListCall

ListOfCampaign returns all ads of a campaign.

func (*AdService) Update

func (as *AdService) Update(ctx context.Context, a Ad) error

Update updates an ad.

type Adaccounts

type Adaccounts struct {
	Data []json.Number `json:"data,omitempty"`
}

Adaccounts https://developers.facebook.com/docs/marketing-api/reference/custom-audience/adaccounts/

type AdsPixel

type AdsPixel struct {
	ID            string  `json:"id"`
	Name          string  `json:"name"`
	CreationTime  fb.Time `json:"creation_time"`
	LastFiredTime fb.Time `json:"last_fired_time"`
}

AdsPixel is a Meta pixel visible to an ad account.

type AdsPixelService

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

AdsPixelService works on ad account pixels.

func (*AdsPixelService) List

func (aps *AdsPixelService) List(ctx context.Context, act string) ([]AdsPixel, error)

List returns the pixels of an ad account.

func (*AdsPixelService) Stats

func (aps *AdsPixelService) Stats(ctx context.Context, pixelID, aggregation string, startTime time.Time) ([]AdsPixelStats, error)

Stats returns the pixel's fired events from the given start time on, aggregated by the given dimension (e.g. "event").

type AdsPixelStats

type AdsPixelStats struct {
	StartTime fb.Time              `json:"start_time"`
	Data      []AdsPixelStatsEntry `json:"data"`
}

AdsPixelStats is one aggregation bucket of pixel stats.

type AdsPixelStatsEntry

type AdsPixelStatsEntry struct {
	Value string `json:"value"`
	Count int64  `json:"count"`
}

AdsPixelStatsEntry holds the count of one aggregation value, e.g. an event name.

type Adset

type Adset struct {
	AccountID                string                 `json:"account_id,omitempty"`
	AttributionSpec          json.RawMessage        `json:"attribution_spec,omitempty"`
	BidAmount                uint64                 `json:"bid_amount,omitempty"`
	BidStrategy              string                 `json:"bid_strategy,omitempty"`
	BillingEvent             string                 `json:"billing_event,omitempty"`
	BudgetRemaining          float64                `json:"budget_remaining,omitempty,string"`
	Campaign                 *Campaign              `json:"campaign,omitempty"`
	CampaignID               string                 `json:"campaign_id,omitempty"`
	ConfiguredStatus         string                 `json:"configured_status,omitempty"`
	CreatedTime              fb.Time                `json:"created_time,omitzero"`
	DailyBudget              float64                `json:"daily_budget,omitempty,string"`
	DailyMinSpendTarget      uint64                 `json:"daily_min_spend_target,omitempty,string"`
	DailySpendCap            uint64                 `json:"daily_spend_cap,omitempty,string"`
	DestinationType          string                 `json:"destination_type,omitempty"`
	DeliveryEstimate         *DeliveryEstimate      `json:"delivery_estimate,omitempty"`
	EffectiveStatus          string                 `json:"effective_status,omitempty"`
	EndTime                  fb.Time                `json:"end_time,omitzero"`
	FrequencyControlSpecs    []FrequencyControlSpec `json:"frequency_control_specs,omitempty"`
	ID                       string                 `json:"id,omitempty"`
	LifetimeBudget           float64                `json:"lifetime_budget,omitempty,string"`
	LifetimeMinSpendTarget   uint64                 `json:"lifetime_min_spend_target,omitempty,string"`
	LifeTimeSpendCap         uint64                 `json:"lifetime_spend_cap,omitempty,string"`
	LifetimeImps             uint64                 `json:"lifetime_imps,omitempty"`
	Name                     string                 `json:"name,omitempty"`
	OptimizationGoal         string                 `json:"optimization_goal,omitempty"`
	PacingType               []string               `json:"pacing_type,omitempty"`
	PlacementSoftOptOut      *PlacementSoftOptOut   `json:"placement_soft_opt_out,omitempty"`
	PromotedObject           *PromotedObject        `json:"promoted_object,omitempty"`
	RecurringBudgetSemantics bool                   `json:"recurring_budget_semantics,omitempty"`
	// fb.Time is a struct, so `omitempty` never drops a zero value (it would marshal as
	// "0001-01-01T00:00:00+0000" and Meta rejects that as a start_time edit on a running ad
	// set). `omitzero` drops the zero value, but is only honored when built with go >= 1.24.
	StartTime                    fb.Time           `json:"start_time,omitzero"`
	Status                       string            `json:"status,omitempty"`
	Targeting                    *Targeting        `json:"targeting,omitempty"`
	UpdatedTime                  fb.Time           `json:"updated_time,omitzero"`
	TargetingOptimizationTypes   map[string]int32  `json:"targeting_optimization_types,omitempty"`
	DSABeneficiary               string            `json:"dsa_beneficiary,omitempty"`
	DSAPayor                     string            `json:"dsa_payor,omitempty"`
	InstagramUserID              string            `json:"instagram_user_id,omitempty"`
	RegionalRegulatedCategories  []string          `json:"regional_regulated_categories,omitempty"`
	RegionalRegulationIdentities map[string]string `json:"regional_regulation_identities,omitempty"`
}

Adset from https://developers.facebook.com/docs/marketing-api/reference/ad-campaign

type AdsetListCall

type AdsetListCall struct {
	*fb.RouteBuilder
	// contains filtered or unexported fields
}

AdsetListCall is used for Listing adsets.

func (*AdsetListCall) Do

func (as *AdsetListCall) Do(ctx context.Context) ([]Adset, error)

Do calls the graph API.

type AdsetService

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

AdsetService is used for working with adsets.

func (*AdsetService) CountAdSets

func (as *AdsetService) CountAdSets(ctx context.Context, accountID string) (uint64, error)

CountAdSets returns the total amount of active adsets.

func (*AdsetService) Create

func (as *AdsetService) Create(ctx context.Context, a Adset) (string, fb.Time, error)

Create uploads a new adset, returns the fields and returns the created adset.

func (*AdsetService) Get

func (as *AdsetService) Get(ctx context.Context, id string, fields ...string) (*Adset, error)

Get returns a single Adset.

func (*AdsetService) GetDeliveryEstimate

func (as *AdsetService) GetDeliveryEstimate(ctx context.Context, id string, t *Targeting) (uint64, error)

GetDeliveryEstimate returns the delivery_estimate mau for a given adset.

func (*AdsetService) List

func (as *AdsetService) List(account string, fields []string) *AdsetListCall

List returns a list of adsets for an account.

func (*AdsetService) ListOfCampaign

func (as *AdsetService) ListOfCampaign(campaignID string, fields []string) *AdsetListCall

ListOfCampaign returns an adsetlistcall for listing the adsets of a campaign id.

func (*AdsetService) Update

func (as *AdsetService) Update(ctx context.Context, a Adset) (fb.Time, error)

Update updates an adset.

type AdvantageStateInfo

type AdvantageStateInfo struct {
	AdvantageState string `json:"advantage_state,omitempty"`
}

AdvantageStateInfo contains read-only information about a campaign's automation state (v23.0+)

type AndroidAppLink struct {
	// The native apps name in the Android store.
	AppName string `json:"app_name,omitempty"`
	// The fully classified class name of the app for intent generation.
	Class string `json:"class,omitempty"`
	// The fully classified package name of the app for intent generation.
	Package string `json:"package,omitempty"`
	// The native Android URL that will be navigated to.
	URL string `json:"url,omitempty"`
}

AndroidAppLink see https://developers.facebook.com/docs/graph-api/reference/android-app-link/

type AssetCustomizationRule

type AssetCustomizationRule struct {
	// Specification of which placements this rule applies to
	CustomizationSpec PlacementCustomizationSpec `json:"customization_spec,omitempty"`
	// Label of the image to use (references AssetFeedSpecImage.AdLabel)
	ImageLabel *AssetLabel `json:"image_label,omitempty"`
	// Label of the video to use (references AssetFeedSpecVideo.AdLabel)
	VideoLabel *AssetLabel `json:"video_label,omitempty"`
	// Label of the body text to use
	BodyLabel *AssetLabel `json:"body_label,omitempty"`
	// Label of the title to use
	TitleLabel *AssetLabel `json:"title_label,omitempty"`
	// Label of the description to use
	DescriptionLabel *AssetLabel `json:"description_label,omitempty"`
	// Label of the link URL to use
	LinkURLLabel *AssetLabel `json:"link_url_label,omitempty"`
	// Label of the CTA to use
	CallToActionTypeLabel *AssetLabel `json:"call_to_action_type_label,omitempty"`
	// Priority of this rule (higher = more important)
	Priority int `json:"priority,omitempty"`
	// Required on the default rule when the creative boosts an existing post (object_story_id)
	UseExistingPost bool `json:"use_existing_post,omitempty"`
}

AssetCustomizationRule defines which assets to use for specific placements

type AssetFeedSpec

type AssetFeedSpec struct {
	// Ad formats to generate
	AdFormats []string `json:"ad_formats,omitempty"`
	// Rules for customizing assets per placement
	AssetCustomizationRules []AssetCustomizationRule `json:"asset_customization_rules,omitempty"`
	// Videos to use in the ad
	Videos []AssetFeedSpecVideo `json:"videos,omitempty"`
	// Images to use in the ad
	Images []AssetFeedSpecImage `json:"images,omitempty"`
	// Body text options
	Bodies []AssetFeedSpecTextAsset `json:"bodies,omitempty"`
	// Title/headline options
	Titles []AssetFeedSpecTextAsset `json:"titles,omitempty"`
	// Description options
	Descriptions []AssetFeedSpecTextAsset `json:"descriptions,omitempty"`
	// Link URLs
	LinkURLs []AssetFeedSpecLinkURL `json:"link_urls,omitempty"`
	// API expects: ["LEARN_MORE", "SHOP_NOW"], NOT objects.
	CallToActionTypes []string `json:"call_to_action_types,omitempty"`
	// Optimization type: DEGREES_OF_FREEDOM (DOF) or ASSET_FEED_STANDARD or ASSET_CUSTOMIZATION
	OptimizationType string `json:"optimization_type,omitempty"`
}

AssetFeedSpec defines different creative assets for dynamic ads or placement-specific customization See https://developers.facebook.com/docs/marketing-api/reference/ad-asset-feed-spec/

type AssetFeedSpecImage

type AssetFeedSpecImage struct {
	Hash     string       `json:"hash,omitempty"`
	URL      string       `json:"url,omitempty"`
	URLTags  string       `json:"url_tags,omitempty"`
	AdLabels []AssetLabel `json:"adlabels,omitempty"`
}

AssetFeedSpecImage represents an image asset in the asset feed

type AssetFeedSpecLinkURL

type AssetFeedSpecLinkURL struct {
	WebsiteURL string       `json:"website_url,omitempty"`
	DisplayURL string       `json:"display_url,omitempty"`
	Deeplink   string       `json:"deeplink,omitempty"`
	AdLabels   []AssetLabel `json:"adlabels,omitempty"`
}

AssetFeedSpecLinkURL represents a link URL asset

type AssetFeedSpecTextAsset

type AssetFeedSpecTextAsset struct {
	Text     string       `json:"text,omitempty"`
	URLTags  string       `json:"url_tags,omitempty"`
	AdLabels []AssetLabel `json:"adlabels,omitempty"`
}

AssetFeedSpecTextAsset represents a text asset (body, title, description)

type AssetFeedSpecVideo

type AssetFeedSpecVideo struct {
	VideoID       string       `json:"video_id,omitempty"`
	URLTags       string       `json:"url_tags,omitempty"`
	ThumbnailHash string       `json:"thumbnail_hash,omitempty"`
	ThumbnailURL  string       `json:"thumbnail_url,omitempty"`
	AdLabels      []AssetLabel `json:"adlabels,omitempty"`
}

AssetFeedSpecVideo represents a video asset in the asset feed

type AssetLabel

type AssetLabel struct {
	// The label name that matches an asset's AdLabel field
	Name string `json:"name,omitempty"`
}

AssetLabel references an asset by its label

type AudienceService

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

AudienceService contains all methods for working on audiences.

func (*AudienceService) Create

func (as *AudienceService) Create(ctx context.Context, act string, a CustomAudience) (string, error)

Create uploads a new custom audience and returns the id of the custom audience.

func (*AudienceService) CreateLookalike

func (as *AudienceService) CreateLookalike(ctx context.Context, adaccountID, orginAudienceID, customAudienceName string, lookalikeSpec *LookalikeSpec) (string, error)

CreateLookalike creates new lookalike

func (*AudienceService) Delete

func (as *AudienceService) Delete(ctx context.Context, id string) error

Delete removes a single audience.

func (*AudienceService) DeleteLookalikes

func (as *AudienceService) DeleteLookalikes(ctx context.Context, id string) error

DeleteLookalikes removes all lookalikes of an audience.

func (*AudienceService) EditIDs

func (as *AudienceService) EditIDs(ctx context.Context, audienceID string, c <-chan string, doRemove bool) error

EditIDs starts adding or removing ids from a custom audience.

func (*AudienceService) Get

Get returns a single audience.

func (AudienceService) GetAudienceSize

func (as AudienceService) GetAudienceSize(ctx context.Context, accountID string, t *Targeting) (AudienceSize, error)

func (*AudienceService) GetSharedAccountInfo

func (as *AudienceService) GetSharedAccountInfo(ctx context.Context, customAudienceID string) ([]SharedAccountInfo, error)

GetSharedAccountInfo returns sharing information for a custom audience.

func (*AudienceService) ListAdAccounts

func (as *AudienceService) ListAdAccounts(ctx context.Context, audienceID string) ([]string, error)

ListAdAccounts lists the accounts an audience is shared to.

func (*AudienceService) ListCustom

func (as *AudienceService) ListCustom(ctx context.Context, act string) ([]CustomAudience, error)

ListCustom returns all custom audiences for that account.

func (*AudienceService) ListCustomFiltered

func (as *AudienceService) ListCustomFiltered(ctx context.Context, act string, filtering []fb.Filter) ([]CustomAudience, error)

ListCustomFiltered returns a filtered list of custom audiences for that account. ...&filtering=[{field:'subtype',operator:'EQUAL',value:'WEBSITE'}].

func (*AudienceService) Share

func (as *AudienceService) Share(ctx context.Context, customAudienceID string, adaccountIDs []string) error

Share shares a custom audience with the provided adaccounts.

func (*AudienceService) ShareCustom

func (as *AudienceService) ShareCustom(ctx context.Context, customAudienceID string, adaccountIDs, relationshipTypes []string) error

ShareCustom shares a custom audience with the provided adaccounts.

func (*AudienceService) UnshareCustom

func (as *AudienceService) UnshareCustom(ctx context.Context, customAudienceID string, adaccountIDs, relationshipTypes []string) error

UnshareCustom unshares a custom audience with the provided adaccounts.

func (*AudienceService) Update

func (as *AudienceService) Update(ctx context.Context, a CustomAudience) error

Update updates an audience.

type AudienceSize

type AudienceSize struct {
	UpperBound uint64 `json:"upper_bound"`
	LowerBound uint64 `json:"lower_bound"`
}

type Business

type Business struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Business is part of a CustomConversion.

type Campaign

type Campaign struct {
	AccountID                   string              `json:"account_id,omitempty"`
	AdvantageStateInfo          *AdvantageStateInfo `json:"advantage_state_info,omitempty"`
	BuyingType                  string              `json:"buying_type,omitempty"`
	CampaignGroupID             string              `json:"campaign_group_id,omitempty"`
	BidStrategy                 string              `json:"bid_strategy,omitempty"`
	BidAmount                   uint64              `json:"bid_amount,omitempty"`
	CanUseSpendCap              bool                `json:"can_use_spend_cap,omitempty"`
	ConfiguredStatus            string              `json:"configured_status,omitempty"`
	CreatedTime                 string              `json:"created_time,omitempty"`
	DailyBudget                 uint64              `json:"daily_budget,omitempty,string"`
	EffectiveStatus             string              `json:"effective_status,omitempty"`
	ID                          string              `json:"id,omitempty"`
	IsAdsetBudgetSharingEnabled bool                `json:"is_adset_budget_sharing_enabled"`
	LifeTimeBudget              uint64              `json:"lifetime_budget,omitempty,string"`
	Name                        string              `json:"name,omitempty"`
	Objective                   string              `json:"objective,omitempty"`
	SpendCap                    uint64              `json:"spend_cap,omitempty,string"`
	StartTime                   fb.Time             `json:"start_time,omitempty"`
	Status                      string              `json:"status,omitempty"`
	StopTime                    fb.Time             `json:"stop_time,omitempty"`
	UpdatedTime                 fb.Time             `json:"updated_time,omitempty"`
	SpecialAdCategories         []string            `json:"special_ad_categories"`
}

Campaign from https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group

type CampaignListCall

type CampaignListCall struct {
	*fb.RouteBuilder
	// contains filtered or unexported fields
}

CampaignListCall is used for listing campaigns.

func (*CampaignListCall) Do

func (csc *CampaignListCall) Do(ctx context.Context) ([]Campaign, error)

Do function performs the CampaignListCall and returns all campaigns as slice.

type CampaignService

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

CampaignService works with campaigns.

func (*CampaignService) Create

func (cs *CampaignService) Create(ctx context.Context, c Campaign) (string, error)

Create uploads a new campaign, returns the fields and returns the created campaign.

func (*CampaignService) Get

func (cs *CampaignService) Get(ctx context.Context, id string, fields ...string) (*Campaign, error)

Get returns a single campaign.

func (*CampaignService) List

func (cs *CampaignService) List(act string) *CampaignListCall

List creates a new CampaignListCall.

func (*CampaignService) ListByEffectiveStatus

func (cs *CampaignService) ListByEffectiveStatus(act string, statuses ...EffectiveStatus) *CampaignListCall

ListByEffectiveStatus returns a CampaignListCall filtered by the given effective_status values. If no statuses are provided, the filter is omitted. Behavior otherwise matches List.

func (*CampaignService) Update

func (cs *CampaignService) Update(ctx context.Context, c Campaign) error

Update updates an campaign.

type City

type City struct {
	Country      string `json:"country"`
	DistanceUnit string `json:"distance_unit"`
	Key          string `json:"key"`
	Name         string `json:"name"`
	Radius       int    `json:"radius"`
	Region       string `json:"region"`
	RegionID     string `json:"region_id"`
}

City can be targeted.

type Comment

type Comment struct {
	ID                       string          `json:"id,omitempty"`
	Attachment               json.RawMessage `json:"attachment,omitempty"`
	CanComment               bool            `json:"can_comment,omitempty"`
	CanRemove                bool            `json:"can_remove,omitempty"`
	CanHide                  bool            `json:"can_hide,omitempty"`
	CanLike                  bool            `json:"can_like,omitempty"`
	CanReplyPrivately        bool            `json:"can_reply_privately,omitempty"`
	CommentCount             int32           `json:"comment_count,omitempty"`
	CreatedTime              fb.Time         `json:"created_time,omitempty"`
	From                     *User           `json:"from,omitempty"`
	LikeCount                int32           `json:"like_count,omitempty"`
	Message                  string          `json:"message,omitempty"`
	MessageTags              []MessageTag    `json:"message_tags,omitempty"`
	Object                   json.RawMessage `json:"object,omitempty"`
	Parent                   *Comment        `json:"parent,omitempty"`
	PrivateReplyConversation json.RawMessage `json:"private_reply_conversation,omitempty"`
	UserLikes                bool            `json:"user_likes,omitempty"`
}

Comment represents a comment on a facebook post.

type CommentListCall

type CommentListCall struct {
	*fb.RouteBuilder

	*fb.StatsContainer
	// contains filtered or unexported fields
}

CommentListCall is used for listing comments of a post.

func (*CommentListCall) List

func (clc *CommentListCall) List(ctx context.Context) ([]Comment, error)

List performs the CommentListCall and returns all comments as slice.

func (*CommentListCall) Read

func (clc *CommentListCall) Read(ctx context.Context, c chan<- Comment) error

type Component

type Component struct {
	Type         string        `json:"type"`
	PositionSpec *PositionSpec `json:"position_spec"`
	PollSpec     *PollSpec     `json:"poll_spec"`
}

Component of the Interactive component struct.

type ConversionActionQuery

type ConversionActionQuery struct {
	ActionType []string `json:"action.type,omitempty"`
	FbPixel    []string `json:"fb_pixel,omitempty"`
	Page       []string `json:"page,omitempty"`
	Post       []string `json:"post,omitempty"`
}

ConversionActionQuery contains tracking specs.

type CreativeFeaturesSpec

type CreativeFeaturesSpec struct {
	InlineComment              *EnrollStatus `json:"inline_comment,omitempty"`                // Opt-in if you want the most relevant comment to be displayed below your ad on Facebook and Instagram.
	ImageTemplate              *EnrollStatus `json:"image_template,omitempty"`                // Opt-in if you want overlays added that show text you have provided along with your selected ad creative when it is likely to improve performance. This feature is generated with AI.
	ImageTouchups              *EnrollStatus `json:"image_touchups,omitempty"`                // Opt-in if you want your chosen media to be automatically cropped and expanded to fit more placements. Only applicable to image ads.
	VideoAutoCrop              *EnrollStatus `json:"video_auto_crop,omitempty"`               // Opt-in if you want your chosen media to be automatically cropped and expanded to fit more placements. Only applicable to video ads.
	ImageBrightnessAndContrast *EnrollStatus `json:"image_brightness_and_contrast,omitempty"` // Opt-in if you want the brightness and contrast of your image to be adjusted when likely to improve performance.
	EnhanceCTA                 *EnrollStatus `json:"enhance_cta,omitempty"`                   // Opt-in if you want keyphrases from your ad sources to be paid with your CTA.
	TextOptimizations          *EnrollStatus `json:"text_optimizations,omitempty"`            // Opt-in if you want text options you provide appear as primary text, headline or description when it’s likely to improve performance. We may add a caption introduction from your headline options and highlight key sentences when it’s likely to improve performance.
	ImageBackgroundGen         *EnrollStatus `json:"image_background_gen,omitempty"`          // Opt-in if you want different backgrounds for eligible product images to be created and the version that your audience is most likely to respond to delivered. This feature is generated with AI.
	ImageUncrop                *EnrollStatus `json:"image_uncrop,omitempty"`                  // Opt-in if you want your image to be automatically expanded to fit more placements. This feature is generated with AI.
	AdaptToPlacement           *EnrollStatus `json:"adapt_to_placement,omitempty"`            // Opt-in if you want 9:16 images in your catalog to be displayed in supported placements (Instagram Stories/Instagram Reels/Facebook Stories/Facebook Reels).
	MediaTypeAutomation        *EnrollStatus `json:"media_type_automation,omitempty"`         // Opt-in if you want videos from your catalog to be displayed (along with images) in supported placements.
	ProductExtensions          *EnrollStatus `json:"product_extensions,omitempty"`            // Opt-in if you want items from your catalog to be shown next to your selected media when it’s likely to improve performance.
}

https://developers.facebook.com/docs/marketing-api/creative/advantage-creative/get-started

type CustomAudience

type CustomAudience struct {
	ID                         string `json:"id,omitempty"`
	Name                       string `json:"name,omitempty"`
	AccountID                  string `json:"account_id,omitempty"`
	Description                string `json:"description,omitempty"`
	Subtype                    string `json:"subtype,omitempty"`
	ApproximateCountUpperBound int    `json:"approximate_count_upper_bound,omitempty"`
	ApproximateCountLowerBound int    `json:"approximate_count_lower_bound,omitempty"`

	Rule               string         `json:"rule,omitempty"`
	CustomerFileSource string         `json:"customer_file_source,omitempty"`
	Lookalikes         []string       `json:"lookalike_audience_ids,omitempty"`
	Adaccounts         *Adaccounts    `json:"adaccounts,omitempty"`
	LookalikeSpec      *LookalikeSpec `json:"lookalike_spec,omitempty"`
	OriginAudienceID   string         `json:"origin_audience_id,omitempty"`
}

CustomAudience https://developers.facebook.com/docs/marketing-api/reference/custom-audience unused fields: ApproximateCount int `json:"approximate_count,omitempty"`.

type CustomConversion

type CustomConversion struct {
	ID                       string       `json:"id"`
	AccountID                string       `json:"account_id"`
	AggregationRule          string       `json:"aggregation_rule"`
	Business                 Business     `json:"business"`
	Name                     string       `json:"name"`
	Rule                     string       `json:"rule"`
	CustomEventType          string       `json:"custom_event_type"`
	CreationTime             fb.Time      `json:"creation_time"`
	DataSources              []DataSource `json:"data_sources"`
	Description              string       `json:"description"`
	DefaultConversionValue   int          `json:"default_conversion_value"`
	LastFiredTime            fb.Time      `json:"last_fired_time"`
	IsUnavailable            bool         `json:"is_unavailable"`
	IsArchived               bool         `json:"is_archived"`
	FirstFiredTime           fb.Time      `json:"first_fired_time"`
	Pixel                    Pixel        `json:"pixel"`
	OfflineConversionDataSet interface{}  `json:"offline_conversion_data_set"`
	EventSourceType          string       `json:"event_source_type"`
	RetentionDays            int          `json:"retention_days"`
}

CustomConversion https://developers.facebook.com/docs/marketing-api/reference/custom-conversion/

type CustomConversionService

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

CustomConversionService contains all methods for working on custom conversions.

func (*CustomConversionService) Create

func (ccs *CustomConversionService) Create(ctx context.Context, businessID string, cc CustomConversion) (string, error)

Create uploads a new custom conversion and returns the id of the custom conversion.

func (*CustomConversionService) List

List returns all custom conversions for the specified account.

type DailyOutcomesCurve

type DailyOutcomesCurve struct {
	Spend       float64 `json:"spend"`
	Reach       float64 `json:"reach"`
	Impressions float64 `json:"impressions"`
	Actions     float64 `json:"actions"`
}

DailyOutcomesCurve talk to phillip.

type Data

type Data struct {
	DailyOutcomesCurve    []DailyOutcomesCurve `json:"daily_outcomes_curve"`
	EstimateDau           int64                `json:"estimate_dau"`
	EstimateMau           int64                `json:"estimate_mau"`
	EstimateMauLowerBound int64                `json:"estimate_mau_lower_bound"`
	EstimateMauUpperBound int64                `json:"estimate_mau_upper_bound"`
	EstimateReady         bool                 `json:"estimate_ready"`
}

Data is a single delivery estimate.

type DataSource

type DataSource struct {
	ID         string `json:"id"`
	SourceType string `json:"source_type"`
}

DataSource is part of a CustomConversion.

type DegreesOfFreedomSpec

type DegreesOfFreedomSpec struct {
	CreativeFeaturesSpec *CreativeFeaturesSpec `json:"creative_features_spec"`
}

type DeliveryEstimate

type DeliveryEstimate struct {
	Data []Data `json:"data"`
}

DeliveryEstimate is a collection of Data structs.

type Device

type Device struct {
	Name         string `json:"name"`
	Description  string `json:"description"`
	Platform     string `json:"platform"`
	AudienceSize int    `json:"audience_size"`
	Type         string `json:"type"`
}

Device contains device information to be used for adset targeting.

type EffectiveStatus

type EffectiveStatus string

EffectiveStatus represents the possible values for a campaign's effective_status field as defined by the Facebook Ads API. Using a typed constant reduces the chance of typos compared to raw string values.

const (
	EffectiveStatusActive             EffectiveStatus = "ACTIVE"
	EffectiveStatusPaused             EffectiveStatus = "PAUSED"
	EffectiveStatusDeleted            EffectiveStatus = "DELETED"
	EffectiveStatusPendingReview      EffectiveStatus = "PENDING_REVIEW"
	EffectiveStatusDisapproved        EffectiveStatus = "DISAPPROVED"
	EffectiveStatusPreApproved        EffectiveStatus = "PREAPPROVED"
	EffectiveStatusPendingBillingInfo EffectiveStatus = "PENDING_BILLING_INFO"
	EffectiveStatusCampaignPaused     EffectiveStatus = "CAMPAIGN_PAUSED"
	EffectiveStatusArchived           EffectiveStatus = "ARCHIVED"
	EffectiveStatusAdsetPaused        EffectiveStatus = "ADSET_PAUSED"
)

type EnrollStatus

type EnrollStatus struct {
	EnrollStatus string `json:"enroll_status"` // OPT_IN or OPT_OUT
}

type EventService

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

EventService contains all methods for working on events.

func (*EventService) SimpleList

func (es *EventService) SimpleList(ctx context.Context, pixelID string) ([]string, error)

SimpleList returns event names for a given pixel id.

type FlexibleSpec

type FlexibleSpec struct {
	CustomAudiences      []IDContainer `json:"custom_audiences,omitempty"`
	Interests            []IDContainer `json:"interests,omitempty"`
	Behaviors            []IDContainer `json:"behaviors,omitempty"`
	LifeEvents           []IDContainer `json:"life_events,omitempty"`
	WorkEmployers        []IDContainer `json:"work_employers,omitempty"`
	FamilyStatuses       []IDContainer `json:"family_statuses,omitempty"`
	WorkPositions        []IDContainer `json:"work_positions,omitempty"`
	Politics             []IDContainer `json:"politics,omitempty"`
	EducationMajors      []IDContainer `json:"education_majors,omitempty"`
	EducationSchools     []IDContainer `json:"education_schools,omitempty"`
	EducationStatuses    []int         `json:"education_statuses,omitempty"`
	RelationshipStatuses []int         `json:"relationship_statuses,omitempty"`
}

FlexibleSpec is used for targeting

type FrequencyControlSpec

type FrequencyControlSpec struct {
	Event        string `json:"event"`
	IntervalDays uint64 `json:"interval_days"`
	MaxFrequency uint64 `json:"max_frequency"`
}

FrequencyControlSpec controls the frequency of an adset.

type GeoLocation

type GeoLocation struct {
	Countries     []string `json:"countries,omitempty"`
	CountryGroups []string `json:"country_groups,omitempty"`
}

GeoLocation ...

type GeoLocations

type GeoLocations struct {
	Countries     []string `json:"countries,omitempty"`
	LocationTypes []string `json:"location_types,omitempty"`
	Cities        []City   `json:"cities,omitempty"`
	Regions       []Region `json:"regions,omitempty"`
	Zips          []Zip    `json:"zips,omitempty"`
}

GeoLocations is a set of countries, cities, and regions that can be targeted.

type IDContainer

type IDContainer struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

IDContainer contains an ID and a name.

type Image

type Image struct {
	ID                              string   `json:"id,omitempty"`
	Height                          int      `json:"height,omitempty"`
	Hash                            string   `json:"hash,omitempty"`
	IsAssociatedCreativesInAdgroups bool     `json:"is_associated_creatives_in_adgroups,omitempty"`
	Name                            string   `json:"name,omitempty"`
	OriginalHeight                  int      `json:"original_height,omitempty"`
	OriginalWidth                   int      `json:"original_width,omitempty"`
	PermalinkURL                    string   `json:"permalink_url,omitempty"`
	Status                          string   `json:"status,omitempty"`
	UpdatedTime                     string   `json:"updated_time,omitempty"`
	CreatedTime                     string   `json:"created_time,omitempty"`
	URL                             string   `json:"url,omitempty"`
	AccountID                       string   `json:"account_id,omitempty"`
	URL128                          string   `json:"url_128,omitempty"`
	Width                           int      `json:"width,omitempty"`
	Creatives                       []string `json:"creatives,omitempty"`
}

Image represents an image being uploaded to the creative library.

type ImageService

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

ImageService works with ad images.

func (*ImageService) ReadList

func (is *ImageService) ReadList(ctx context.Context, act string, res chan<- Image) error

ReadList writes all ad images from an account to res.

func (*ImageService) Upload

func (is *ImageService) Upload(ctx context.Context, act, name string, r io.Reader) (*Image, error)

Upload uploads an image to Facebook.

type IndividualSetting

type IndividualSetting struct {
	Age    int8 `json:"age,omitempty"`
	Gender int8 `json:"gender,omitempty"`
}

IndividualSetting contains age and gender suggestion settings (v23.0+)

type Insight

type Insight struct {
	AccountID                        string                 `json:"account_id"`
	Actions                          ActionTypeValue        `json:"actions"`
	ActionValues                     ActionTypeValue        `json:"action_values"`
	AdsetID                          string                 `json:"adset_id"`
	AdID                             string                 `json:"ad_id"`
	Objective                        string                 `json:"objective"`
	AdsetName                        string                 `json:"adset_name"`
	Age                              string                 `json:"age"`
	CampaignID                       string                 `json:"campaign_id"`
	CampaignName                     string                 `json:"campaign_name"`
	PublisherPlatform                string                 `json:"publisher_platform"`
	PlatformPosition                 string                 `json:"platform_position"`
	Clicks                           uint64                 `json:"clicks,string"`
	DateStart                        string                 `json:"date_start"`
	DateStop                         string                 `json:"date_stop"`
	Frequency                        float64                `json:"frequency,string"`
	Gender                           string                 `json:"gender"`
	Impressions                      uint64                 `json:"impressions,string"`
	Reach                            float64                `json:"reach,string"`
	Spend                            float64                `json:"spend,string"`
	VideoContinues2SecWatchedActions ActionTypeValue        `json:"video_continuous_2_sec_watched_actions"`
	Video15SecWatchedActions         ActionTypeValue        `json:"video_15_sec_watched_actions"`
	VideoThruplayWatchedActions      ActionTypeValue        `json:"video_thruplay_watched_actions"`
	Video30SecWatchedActions         ActionTypeValue        `json:"video_30_sec_watched_actions"`
	VideoAvgTimeWatchedActions       ActionTypeValue        `json:"video_avg_time_watched_actions"`
	VideoP100WatchedActions          ActionTypeValue        `json:"video_p100_watched_actions"`
	VideoP25WatchedActions           ActionTypeValue        `json:"video_p25_watched_actions"`
	VideoP50WatchedActions           ActionTypeValue        `json:"video_p50_watched_actions"`
	VideoP75WatchedActions           ActionTypeValue        `json:"video_p75_watched_actions"`
	VideoP95WatchedActions           ActionTypeValue        `json:"video_p95_watched_actions"`
	VideoPlayActions                 ActionTypeValue        `json:"video_play_actions"`
	InteractiveComponentTap          []InteractiveComponent `json:"interactive_component_tap"`
	DeviceType                       string                 `json:"impression_device"`
	Region                           string                 `json:"region"`
	Country                          string                 `json:"country"`
}

Insight contains insight data for an facebook graph API object, broken down by the desired day.

func (Insight) GetAge

func (i Insight) GetAge() (uint64, uint64, error)

GetAge returns the min and max age from the insights age field.

type InsightsRequest

type InsightsRequest struct {
	*InsightsService
	*fb.RouteBuilder
}

InsightsRequest is used to build a new request for creating an insights run.

func (*InsightsRequest) Download

func (ir *InsightsRequest) Download(ctx context.Context) ([]Insight, error)

Download returns all insights from the request in one slice.

func (*InsightsRequest) GenerateReport

func (ir *InsightsRequest) GenerateReport(ctx context.Context, c chan<- Insight) (uint64, error)

GenerateReport creates the insights report, waits until it's finished building, reads to c and then deletes it.

type InsightsService

type InsightsService struct {
	*fb.StatsContainer
	// contains filtered or unexported fields
}

InsightsService contains all methods for working on audiences.

func (*InsightsService) NewReport

func (is *InsightsService) NewReport(account string) *InsightsRequest

NewReport creates a new InsightsRequest.

func (*InsightsService) NewReportOfCampaign

func (is *InsightsService) NewReportOfCampaign(campaignID string) *InsightsRequest

NewReportOfCampaign creates a new InsightsRequest.

type InstagramComment

type InstagramComment struct {
	ID        string  `json:"id,omitempty"`
	Text      string  `json:"text,omitempty"`
	LikeCount uint64  `json:"like_count,omitempty"`
	Timestamp fb.Time `json:"timestamp,omitempty"`
}

type InstagramPost

type InstagramPost struct {
	ID        string `json:"id,omitempty"`
	IgID      string `json:"ig_id,omitempty"`
	Shortcode string `json:"shortcode,omitempty"`
	Permalink string `json:"permalink,omitempty"`
	Owner     struct {
		ID string `json:"id,omitempty"`
	} `json:"owner,omitempty"`
	Caption              string `json:"caption,omitempty"`
	LikeCount            uint64 `json:"like_count,omitempty"`
	CommentsCount        uint64 `json:"comments_count,omitempty"`
	MediaType            string `json:"media_type,omitempty"`
	BoostEligibilityInfo struct {
		EligibleToBoost bool `json:"eligible_to_boost,omitempty"`
	} `json:"boost_eligibility_info,omitempty"`
}

type InstagramPostListCall

type InstagramPostListCall struct {
	*fb.RouteBuilder
	// contains filtered or unexported fields
}

InstagramPostListCall is used for listing media posts of an IG user.

func (*InstagramPostListCall) Do

Do calls the graph API and returns all matching posts as a slice.

type InstagramUser

type InstagramUser struct {
	ID       string `json:"id"`
	Username string `json:"username"`
}

InstagramActor represents an instagram actor.

type InteractiveComponent

type InteractiveComponent struct {
	InteractiveComponentStickerID       string `json:"interactive_component_sticker_id"`
	InteractiveComponentStickerResponse string `json:"interactive_component_sticker_response"`
	Value                               string `json:"value"`
}

InteractiveComponent represents poll results.

type InteractiveComponentsSpec

type InteractiveComponentsSpec struct {
	Components []*Component `json:"components"`
}

InteractiveComponentsSpec is mainly used for Video Poll Ads.

type InterestService

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

InterestService works with ads interests.

func (*InterestService) Search

func (is *InterestService) Search(ctx context.Context, query string, limit int) ([]InterestTargeting, error)

Search returns a list of InterestTargetings.

func (*InterestService) TargetingSearch

func (is *InterestService) TargetingSearch(ctx context.Context, act, query, limitType string) ([]InterestTargeting, error)

TargetingSearch searches for a targeting. limitType filters results by targeting category (e.g. "interests", "behaviors", "keywords", etc.). https://developers.facebook.com/docs/marketing-api/reference/ad-account/targetingsearch/

type InterestTargeting

type InterestTargeting struct {
	ID           string   `json:"id"`
	Name         string   `json:"name"`
	AudienceSize uint64   `json:"audience_size_upper_bound"`
	Type         string   `json:"type"`
	Path         []string `json:"path"`
}

InterestTargeting represents an ad interest to be used in an adset targeting.

type IosAppLink struct {
	// The native apps name in the iTunes store.
	AppName string `json:"app_name,omitempty"`
	// The native apps ID in the iTunes store.
	AppStoreID string `json:"app_store_id,omitempty"`
	// The native iOS URL that will be navigated to.
	URL string `json:"url,omitempty"`
}

IosAppLink see https://developers.facebook.com/docs/graph-api/reference/ios-app-link/

type LocationSpec

type LocationSpec struct {
	GeoLocations         *GeoLocation `json:"geo_locations,omitempty"`
	ExcludedGeoLocations *GeoLocation `json:"excluded_geo_locations,omitempty"`
}

LocationSpec ...

type LookalikeOrigion

type LookalikeOrigion struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
}

LookalikeOrigion tells which audience a lookalike one is related to.

type LookalikeSpec

type LookalikeSpec struct {
	Country       string             `json:"country,omitempty"`
	Origin        []LookalikeOrigion `json:"origin,omitempty"`
	Ratio         float64            `json:"ratio,omitempty"`
	Type          string             `json:"type,omitempty"`
	StartingRatio float64            `json:"starting_ratio,omitempty"`
}

LookalikeSpec contains the metadata of lookalike audiences.

type MessageTag

type MessageTag struct {
	ID     string `json:"id,omitempty"`
	Name   string `json:"name,omitempty"`
	Type   string `json:"type,omitempty"`
	Offset int    `json:"offset,omitempty"`
	Length int    `json:"length,omitempty"`
}

MessageTag represents a tagged user or site in a comment.

type ObjectStorySpec

type ObjectStorySpec struct {
	PageID          string               `json:"page_id,omitempty"`
	InstagramUserID string               `json:"instagram_user_id,omitempty"`
	VideoData       *VideoData           `json:"video_data,omitempty"`
	LinkData        *AdCreativeLinkData  `json:"link_data,omitempty"`
	PhotoData       *AdCreativePhotoData `json:"photo_data,omitempty"`
}

ObjectStorySpec contains the media of a creative.

type OperatingSystem

type OperatingSystem struct {
	Type        string `json:"type"`
	Name        string `json:"name"`
	Platform    string `json:"platform"`
	Description string `json:"description"`
}

OperatingSystem contains information about an user OS to be used for adset targeting.

type OptionCallToAction

type OptionCallToAction struct {
	Value *OptionCallToActionValue `json:"value"`
	Type  string                   `json:"type"`
}

OptionCallToAction represents the action and call to action of an answer of a poll.

type OptionCallToActionValue

type OptionCallToActionValue struct {
	Link       string `json:"link"`
	LinkFormat string `json:"link_format,omitempty"`
}

OptionCallToActionValue describes the link of a call to action answer.

type Page

type Page struct {
	ID                  string `json:"id"`
	GlobalBrandPageName string `json:"global_brand_page_name"`
}

Page represents a facebook page.

type PageService

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

PageService contains all methods for working on pages.

func (*PageService) Get

func (ps *PageService) Get(ctx context.Context, id string) (*Page, error)

Get returns a single page.

func (*PageService) GetClientPages

func (ps *PageService) GetClientPages(ctx context.Context, businessID string) ([]Page, error)

GetClientPages returns all client pages.

func (*PageService) GetInstagramBusinessAccount

func (ps *PageService) GetInstagramBusinessAccount(ctx context.Context, pageID string) (*InstagramUser, error)

GetPageBackedInstagramAccounts returns the instagram actor associated with a facebook page.

func (*PageService) GetInstagramUser

func (ps *PageService) GetInstagramUser(ctx context.Context, id string) (*InstagramUser, error)

GetInstagramUser returns a single instagram user.

func (*PageService) GetInstagramUsers

func (ps *PageService) GetInstagramUsers(ctx context.Context, businessID string) ([]InstagramUser, error)

GetInstagramUsers returns all instagram accounts.

func (*PageService) GetOwnedPages

func (ps *PageService) GetOwnedPages(ctx context.Context, businessID string) ([]Page, error)

GetOwnedPages returns all owned pages.

func (*PageService) ListIGUsers

func (ps *PageService) ListIGUsers(ctx context.Context) ([]InstagramUser, error)

func (*PageService) SetPageAccessToken

func (ps *PageService) SetPageAccessToken(ctx context.Context, pageID string) (context.Context, error)

SetPageAccessToken tries to retrieve the access token for a facebook page and includes it in the passed context so the fb.Client can use it for making requests.

type Pixel

type Pixel struct {
	ID string `json:"id"`
}

Pixel is part of a CustomConversion.

type PlacementCustomizationSpec

type PlacementCustomizationSpec struct {
	// Publisher platforms: facebook, instagram, audience_network, messenger
	PublisherPlatforms []string `json:"publisher_platforms,omitempty"`
	// Facebook positions: feed, right_hand_column, instant_article, marketplace, video_feeds, story, search, instream_video, facebook_reels
	FacebookPositions []string `json:"facebook_positions,omitempty"`
	// Instagram positions: stream, story, explore, reels, profile_feed, ig_search, profile_reels
	InstagramPositions []string `json:"instagram_positions,omitempty"`
	// Audience network positions: classic, rewarded_video
	AudienceNetworkPositions []string `json:"audience_network_positions,omitempty"`
	// Messenger positions: messenger_home, story, sponsored_messages
	MessengerPositions []string `json:"messenger_positions,omitempty"`
}

PlacementCustomizationSpec specifies which placements a customization rule applies to

type PlacementSoftOptOut

type PlacementSoftOptOut struct {
	FacebookPositions        Positions `json:"facebook_positions"`
	AudienceNetworkPositions Positions `json:"audience_network_positions"`
	InstagramPositions       Positions `json:"instagram_positions"`
	ThreadsPositions         Positions `json:"threads_positions"`
	MessengerPositions       Positions `json:"messenger_positions"`
}

PlacementSoftOptOut contains the excluded placement positions Meta may still spend a limited budget on ("allow limited spending to excluded placements").

type PollSpec

type PollSpec struct {
	QuestionText        string              `json:"question_text"`
	OptionAText         string              `json:"option_a_text"`
	OptionBText         string              `json:"option_b_text"`
	ThemeColor          string              `json:"theme_color,omitempty"`
	OptionACallToAction *OptionCallToAction `json:"option_a_call_to_action,omitempty"`
	OptionBCallToAction *OptionCallToAction `json:"option_b_call_to_action,omitempty"`
	LinkDisplay         string              `json:"link_display,omitempty"`
}

PollSpec represents the questions and answers of a poll.

type PositionSpec

type PositionSpec struct {
	X        float64 `json:"x"`
	Y        float64 `json:"y"`
	Width    float64 `json:"width"`
	Height   float64 `json:"height"`
	Rotation float64 `json:"rotation"`
}

PositionSpec describes the position of an interactive component.

type Positions

type Positions []string

Positions is a placement position list that marshals as an explicit empty array when nil: Meta treats null or missing position lists as "keep the current value", so only [] can clear one.

func (Positions) MarshalJSON

func (p Positions) MarshalJSON() ([]byte, error)

MarshalJSON emits [] instead of null for a nil list.

type Post

type Post struct {
	CreatedTime            string                          `json:"created_time"`
	ContentCategory        string                          `json:"content_category"`
	Description            string                          `json:"description"`
	EmbedHTML              string                          `json:"embed_html"`
	Embeddable             bool                            `json:"embeddable"`
	ID                     string                          `json:"id"`
	Icon                   string                          `json:"icon"`
	IsInstagramEligible    bool                            `json:"is_instagram_eligible"`
	Picture                string                          `json:"picture"`
	PermalinkURL           string                          `json:"permalink_url"`
	MonetizationStatus     string                          `json:"monetization_status"`
	Length                 float64                         `json:"length"`
	Link                   string                          `json:"link"`
	Name                   string                          `json:"name"`
	Type                   string                          `json:"type"`
	Published              bool                            `json:"published"`
	UpdatedTime            string                          `json:"updated_time"`
	Message                string                          `json:"message"`
	InstagramEligibility   string                          `json:"instagram_eligibility"`
	FullPicture            string                          `json:"full_picture"`
	MultiShareEndCard      bool                            `json:"multi_share_end_card"`
	MultiShareOptimized    bool                            `json:"multi_share_optimized"`
	ObjectID               string                          `json:"object_id"`
	PromotableID           string                          `json:"promotable_id"`
	IsEligibleForPromotion bool                            `json:"is_eligible_for_promotion"`
	PromotionStatus        string                          `json:"promotion_status"`
	StatusType             string                          `json:"status_type"`
	Subscribed             bool                            `json:"subscribed"`
	TimelineVisibility     string                          `json:"timeline_visibility"`
	VideoBuyingEligibility []string                        `json:"video_buying_eligibility"`
	IsHidden               bool                            `json:"is_hidden"`
	IsAppShare             bool                            `json:"is_app_share"`
	IsExpired              bool                            `json:"is_expired"`
	IsPopular              bool                            `json:"is_popular"`
	IsPublished            bool                            `json:"is_published"`
	IsSpherical            bool                            `json:"is_spherical"`
	CallToAction           *AdCreativeLinkDataCallToAction `json:"call_to_action"`
	Format                 []struct {
		EmbedHTML string `json:"embed_html"`
		Filter    string `json:"filter"`
		Height    int    `json:"height"`
		Picture   string `json:"picture"`
		Width     int    `json:"width"`
	} `json:"format"`
	From    IDContainer `json:"from"`
	Privacy struct {
		Allow       string `json:"allow"`
		Deny        string `json:"deny"`
		Description string `json:"description"`
		Friends     string `json:"friends"`
		Networks    string `json:"networks"`
		Value       string `json:"value"`
	} `json:"privacy"`
	Status struct {
		VideoStatus string `json:"video_status"`
	} `json:"status"`
	Application struct {
		Category string `json:"category"`
		Link     string `json:"link"`
		Name     string `json:"name"`
		ID       string `json:"id"`
	} `json:"application"`
	Coordinates struct{} `json:"coordinates"`
	Actions     []struct {
		Name string `json:"name"`
		Link string `json:"link"`
	} `json:"actions"`
	Properties []struct {
		Name string `json:"name"`
		Text string `json:"text"`
	} `json:"properties"`
}

Post represents the fb graph api response for a fb video post https://developers.facebook.com/docs/graph-api/reference/v5.0/page-post

type PostListCall

type PostListCall struct {
	*fb.RouteBuilder
	// contains filtered or unexported fields
}

PostListCall is used for listing posts of a page.

func (*PostListCall) Do

func (plc *PostListCall) Do(ctx context.Context) ([]Post, error)

Do calls the graph API and returns all posts as a slice.

type PostService

type PostService struct {
	*fb.StatsContainer
	// contains filtered or unexported fields
}

PostService works on posts.

func (*PostService) CountComments

func (ps *PostService) CountComments(ctx context.Context, postID string) (uint64, error)

CountComments returns the total amount of parent comments.

func (*PostService) CountCommentsByPostIDs

func (ps *PostService) CountCommentsByPostIDs(ctx context.Context, postIDs []string) (map[string]uint64, error)

CountCommentsByPostIDs returns comment counts keyed by post ID. Attached objects are resolved when the post itself reports no comments.

func (*PostService) Get

func (ps *PostService) Get(ctx context.Context, id string) (*Post, error)

Get returns a single post.

func (*PostService) GetInstagramPermalinksByMediaIDs

func (ps *PostService) GetInstagramPermalinksByMediaIDs(ctx context.Context, mediaIDs []string) (map[string]string, error)

GetInstagramPermalinksByMediaIDs returns permalinks keyed by media ID.

func (*PostService) GetInstagramPost

func (ps *PostService) GetInstagramPost(ctx context.Context, postID string) (*InstagramPost, error)

func (*PostService) GetPostID

func (ps *PostService) GetPostID(ctx context.Context, pID string) (*string, error)

Get postID from image/video/carousel post

func (*PostService) GetReactions

func (ps *PostService) GetReactions(ctx context.Context, postID string) (Reactions, error)

GetReactions returns the amount of reactions for a post.

func (*PostService) ListComments

func (ps *PostService) ListComments(postID, filter string) *CommentListCall

ListComments creates a new CommentListCall Filters may be "stream" or "toplevel".

func (*PostService) ListInstagramComments

func (ps *PostService) ListInstagramComments(ctx context.Context, postID string, c chan<- InstagramComment) (uint64, error)

func (*PostService) ListInstagramCommentsByMediaIDs

func (ps *PostService) ListInstagramCommentsByMediaIDs(ctx context.Context, mediaIDs []string) (map[string][]InstagramComment, error)

ListInstagramCommentsByMediaIDs returns comments and replies grouped by media ID.

func (*PostService) ListInstagramPosts

func (ps *PostService) ListInstagramPosts(ctx context.Context, igUserID string, c chan<- InstagramPost) (uint64, error)

GetClientPages returns all client pages.

func (*PostService) ListOfInstagramUser

func (ps *PostService) ListOfInstagramUser(igUserID string) *InstagramPostListCall

ListOfInstagramUser returns an InstagramPostListCall for listing media of an IG user.

func (*PostService) ListOfPage

func (ps *PostService) ListOfPage(pageID string, fields []string) *PostListCall

ListOfPage returns a PostListCall for listing posts of a page.

func (*PostService) SetPageAccessToken

func (ps *PostService) SetPageAccessToken(ctx context.Context, pageID string) (context.Context, error)

SetPageAccessToken tries to retrieve the access token for a facebook page and includes it in the passed context so the fb.Client can use it for making requests.

type PromotedObject

type PromotedObject struct {
	PageID             string `json:"page_id,omitempty"`
	PixelID            string `json:"pixel_id,omitempty"`
	PixelRule          string `json:"pixel_rule,omitempty"`
	CustomEventType    string `json:"custom_event_type,omitempty"`
	CustomConversionID string `json:"custom_conversion_id,omitempty"`
}

PromotedObject contains the id of a promoted page.

type ReachEstimate

type ReachEstimate struct {
	Data ReachEstimateData `json:"data"`
}

ReachEstimate is a collection of Data structs.

type ReachEstimateData

type ReachEstimateData struct {
	LowerBound    uint64 `json:"users_lower_bound"`
	UpperBound    uint64 `json:"users_upper_bound"`
	EstimateReady bool   `json:"estimate_ready"`
}

Data is a single reach estimate.

type Reactions

type Reactions map[string]uint64

Reactions contains a reation and how often it was performed on an object.

type Region

type Region struct {
	Key     string `json:"key"`
	Name    string `json:"name"`
	Country string `json:"country"`
}

Region can be targeted.

type SearchService

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

SearchService performs searches on the graph API.

func (*SearchService) GetAdGeoLocations

func (s *SearchService) GetAdGeoLocations(ctx context.Context) ([]AdGeoLocation, error)

GetAdGeoLocations returns all AdGeoLocations.

func (*SearchService) GetAdLocales

func (s *SearchService) GetAdLocales(ctx context.Context) ([]AdLocale, error)

GetAdLocales returns all ad locales.

func (*SearchService) GetDevices

func (s *SearchService) GetDevices(ctx context.Context) ([]Device, error)

GetDevices returns all devices.

func (*SearchService) GetOperatingSystems

func (s *SearchService) GetOperatingSystems(ctx context.Context) ([]OperatingSystem, error)

GetOperatingSystems returns all operating systems.

func (*SearchService) GetRegions

func (s *SearchService) GetRegions(ctx context.Context, country string) ([]AdGeoLocation, error)

func (*SearchService) ValidateInterests

func (s *SearchService) ValidateInterests(ctx context.Context, externalIDs []string) (validIDs []string, invalidIDs []string, err error)

ValidateInterests validates a list of interests and returns a list of valid and a list of invalid IDs.

type Service

type Service struct {
	*fb.Client
	AdAccounts        *AdAccountService
	AdCreatives       *AdCreativeService
	Adsets            *AdsetService
	Ads               *AdService
	AdsPixels         *AdsPixelService
	Audiences         *AudienceService
	Campaigns         *CampaignService
	CustomConversions *CustomConversionService
	Events            *EventService
	Insights          *InsightsService
	Interests         *InterestService
	Images            *ImageService
	Pages             *PageService
	Posts             *PostService
	Search            *SearchService
	Videos            *VideoService
}

Service interacts with the Facebook Marketing API.

func New

func New(l log.Logger, accessToken, appSecret string) (*Service, error)

New initializes a new Service and all the Services contained.

func NewWithClient

func NewWithClient(l log.Logger, c *fb.Client) (*Service, error)

NewWithClient initializes a new Service using a pre-configured fb.Client. The client is validated by making a /me call.

func NewWithConfig

func NewWithConfig(l log.Logger, accessToken, appSecret string, cfg fb.RateLimitConfig) (*Service, error)

NewWithConfig initializes a new Service with the given rate-limit configuration.

func (*Service) GetMetadata

func (s *Service) GetMetadata(ctx context.Context, id string) (*fb.Metadata, error)

GetMetadata returns the metadata of a graph API object.

type SharedAccountInfo

type SharedAccountInfo struct {
	AccountID string `json:"account_id"`
	Business  struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"business"`
}

type StoryAttachment

type StoryAttachment struct {
	Description         string                 `json:"description,omitempty"`
	Media               *StoryAttachmentMedia  `json:"media,omitempty"`
	MediaType           string                 `json:"media_type,omitempty"`
	Title               string                 `json:"title,omitempty"`
	StoryAttachmentType string                 `json:"type,omitempty"`
	UnshimmedURL        string                 `json:"unshimmed_url,omitempty"`
	URL                 string                 `json:"url,omitempty"`
	Name                string                 `json:"name,omitempty"`
	Target              *StoryAttachmentTarget `json:"target,omitempty"`
}

StoryAttachment holds information about a post, used since v3.3 https://developers.facebook.com/docs/graph-api/reference/story-attachment/

type StoryAttachmentMedia

type StoryAttachmentMedia struct {
	Image  interface{} `json:"image,omitempty"`
	Source string      `json:"source,omitempty"`
}

StoryAttachmentMedia https://developers.facebook.com/docs/graph-api/reference/v5.0/story-attachment-media

type StoryAttachmentTarget

type StoryAttachmentTarget struct {
	ID           string `json:"id,omitempty"`
	UnshimmedURL string `json:"unshimmed_url,omitempty"`
	URL          string `json:"url,omitempty"`
}

StoryAttachmentTarget https://developers.facebook.com/docs/graph-api/reference/story-attachment-target/

type StoryAttachments

type StoryAttachments struct {
	Data []StoryAttachment `json:"data,omitempty"`
}

StoryAttachments wraps the data slice around the StoryAttachment(s).

type Targeting

type Targeting struct {
	// inventories
	PublisherPlatforms []string `json:"publisher_platforms,omitempty"`
	// sub inventories
	FacebookPositions        []string `json:"facebook_positions,omitempty"`
	InstagramPositions       []string `json:"instagram_positions,omitempty"`
	AudienceNetworkPositions []string `json:"audience_network_positions,omitempty"`
	MessengerPositions       []string `json:"messenger_positions,omitempty"`

	AgeMin uint64 `json:"age_min,omitempty"`
	AgeMax uint64 `json:"age_max,omitempty"`
	// AgeRange is the [min, max] age suggestion used with Advantage+ audience;
	// unlike age_min/age_max it is not a hard constraint (v23.0+).
	AgeRange []uint64 `json:"age_range,omitempty"`
	Genders  []int    `json:"genders,omitempty"`

	AppInstallState string `json:"app_install_state,omitempty"`

	CustomAudiences         []IDContainer  `json:"custom_audiences,omitempty"`
	ExcludedCustomAudiences []IDContainer  `json:"excluded_custom_audiences,omitempty"`
	GeoLocations            *GeoLocations  `json:"geo_locations,omitempty"`
	ExcludedGeoLocations    *GeoLocations  `json:"excluded_geo_locations,omitempty"`
	FlexibleSpec            []FlexibleSpec `json:"flexible_spec,omitempty"`
	Exclusions              *FlexibleSpec  `json:"exclusions,omitempty"`

	DevicePlatforms             []string                 `json:"device_platforms,omitempty"`
	ExcludedPublisherCategories []string                 `json:"excluded_publisher_categories,omitempty"`
	Locales                     []int                    `json:"locales,omitempty"`
	TargetingAutomation         *TargetingAutomation     `json:"targeting_automation,omitempty"`
	TargetingOptimization       string                   `json:"targeting_optimization,omitempty"`
	UserDevice                  []string                 `json:"user_device,omitempty"`
	UserOs                      []string                 `json:"user_os,omitempty"`
	WirelessCarrier             []string                 `json:"wireless_carrier,omitempty"`
	TargetingRelaxationTypes    TargetingRelaxationTypes `json:"targeting_relaxation_types,omitempty"`
}

Targeting contains all the targeting information of an adset.

type TargetingAutomation

type TargetingAutomation struct {
	AdvantageAudience int8               `json:"advantage_audience"` // 0 = disabled, 1 = enabled
	IndividualSetting *IndividualSetting `json:"individual_setting,omitempty"`
}

TargetingAutomation allows age and gender settings to be used as suggestions (v23.0+)

type TargetingOptionStatus

type TargetingOptionStatus struct {
	ID            string `json:"id"`
	CurrentStatus string `json:"current_status"`
	FuturePlan    []struct {
		Key   string `json:"key"`
		Value string `json:"value"`
	} `json:"future_plan"`
}

TargetingOptionStatus is the json response of the ValidateInterest request.

type TargetingRelaxationTypes

type TargetingRelaxationTypes struct {
	CustomAudience int8 `json:"custom_audience"`
	Lookalike      int8 `json:"lookalike"`
}

Advantage custom audience and Advantage lookalike can be enabled or disabled. if a value of 0 is passed, it will be disabled. If a value of 1 is passed, it will be enabled. If no key/value pair is passed, it will be considered as enabled. https://developers.facebook.com/docs/graph-api/changelog/version15.0/

type TargetingValidationResult

type TargetingValidationResult struct {
	ID    string `json:"id"`
	Valid bool   `json:"valid"`
}

TargetingValidationResult is a single entry returned by the targetingvalidation endpoint.

type UploadError

type UploadError struct {
	Total    uint64
	Received uint64
	Failed   uint64
}

UploadError gets returned when the number of total lines does not match the number of received lines or when the number of failed lines is greater than zero.

func (*UploadError) Error

func (ue *UploadError) Error() string

type User

type User struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

User represents a facebook user.

type Video

type Video struct {
	ContentCategory        string  `json:"content_category"`
	CreatedTime            string  `json:"created_time"`
	Description            string  `json:"description"`
	EmbedHTML              string  `json:"embed_html"`
	Embeddable             bool    `json:"embeddable"`
	ID                     string  `json:"id"`
	Icon                   string  `json:"icon"`
	Length                 float64 `json:"length"`
	MonetizationStatus     string  `json:"monetization_status"`
	Picture                string  `json:"picture"`
	IsCrosspostVideo       bool    `json:"is_crosspost_video"`
	IsCrosspostingEligible bool    `json:"is_crossposting_eligible"`
	IsInstagramEligible    bool    `json:"is_instagram_eligible"`
	PermalinkURL           string  `json:"permalink_url"`
	Published              bool    `json:"published"`
	Source                 string  `json:"source"`
	UpdatedTime            string  `json:"updated_time"`
	Title                  string  `json:"title,omitempty"`
	AutoGeneratedCaptions  struct {
		Data []struct {
			ID string `json:"id"`
		} `json:"data"`
		Paging struct {
			Cursors struct {
				Before string `json:"before"`
				After  string `json:"after"`
			} `json:"cursors"`
		} `json:"paging"`
	} `json:"auto_generated_captions,omitempty"`
	Format []struct {
		EmbedHTML string `json:"embed_html"`
		Filter    string `json:"filter"`
		Height    int    `json:"height"`
		Picture   string `json:"picture"`
		Width     int    `json:"width"`
	} `json:"format"`
	From struct {
		Name string `json:"name"`
		ID   string `json:"id"`
	} `json:"from"`
	Privacy struct {
		Allow       string `json:"allow"`
		Deny        string `json:"deny"`
		Description string `json:"description"`
		Friends     string `json:"friends"`
		Networks    string `json:"networks"`
		Value       string `json:"value"`
	} `json:"privacy"`
	Status struct {
		VideoStatus string `json:"video_status"`
	} `json:"status"`
}

Video represents an ad video.

type VideoData

type VideoData struct {
	ImageHash       string                          `json:"image_hash,omitempty"`
	ImageURL        string                          `json:"image_url,omitempty"`
	LinkDescription string                          `json:"link_description,omitempty"`
	Message         string                          `json:"message,omitempty"`
	Title           string                          `json:"title,omitempty"`
	VideoID         string                          `json:"video_id,omitempty"`
	CallToAction    *AdCreativeLinkDataCallToAction `json:"call_to_action,omitempty"`
}

VideoData is the specific part of a creative that only video posts do have.

type VideoService

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

VideoService works with advideos.

func (*VideoService) Get

func (vs *VideoService) Get(ctx context.Context, id string) (*Video, error)

Get returns a single Video.

func (*VideoService) ReadList

func (vs *VideoService) ReadList(ctx context.Context, act string, res chan<- Video) error

ReadList returns all videos from an account and writes them to a channel.

func (*VideoService) Thumbnails

func (vs *VideoService) Thumbnails(ctx context.Context, videoID string) ([]VideoThumbnail, error)

Thumbnails returns the thumbnails edge for a video (GET /{video_id}/thumbnails). Unlike Video.Picture — which can return Facebook's generic placeholder while the video is still processing — this endpoint returns extracted frames with an explicit is_preferred flag.

func (*VideoService) Upload

func (vs *VideoService) Upload(ctx context.Context, act, title string, size int64, r io.Reader) (*Video, error)

Upload uploads a video from r into an account and returns the video with the fields listed in advideoFields populated.

The trailing Get happens immediately after the upload finishes, while Meta is still asynchronously rendering format variants. Requesting `format` (and to a lesser extent `picture`) at that moment can trip Meta's response-size guard and return "Please reduce the amount of data you're asking for". Callers that only need the resulting video ID should prefer UploadWithoutFetch.

func (*VideoService) UploadWithoutFetch

func (vs *VideoService) UploadWithoutFetch(ctx context.Context, act, title string, size int64, r io.Reader) (*Video, error)

UploadWithoutFetch uploads a video from r into an account and returns a minimally populated Video containing only the resulting ID. It skips the trailing fields fetch that Upload performs, avoiding "Please reduce the amount of data you're asking for" errors that Meta intermittently returns while a freshly uploaded video is still being transcoded.

Use this when the caller only needs the video ID (e.g. to attach the asset to a creative). Callers that need title/picture/format/etc. should either use Upload or call Get separately, after Meta has had time to finish encoding.

type VideoThumbnail

type VideoThumbnail struct {
	ID          string  `json:"id"`
	URI         string  `json:"uri"`
	IsPreferred bool    `json:"is_preferred"`
	Height      int     `json:"height"`
	Width       int     `json:"width"`
	Scale       float64 `json:"scale"`
}

VideoThumbnail represents a single entry on the /{video_id}/thumbnails edge.

type Zip

type Zip struct {
	Key           string `json:"key"`
	Name          string `json:"name"`
	PrimaryCityID int    `json:"primary_city_id"`
	RegionID      int    `json:"region_id"`
	Country       string `json:"country"`
}

Zip can be targeted.

Jump to

Keyboard shortcuts

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