Documentation ¶
Index ¶
- Constants
- func DelClient(names ...string)
- func Init(ctx context.Context, configs ...Config) (err error)
- type Account
- type AccountResponse
- type AllDataItem
- type AllDataResponse
- type ApiAccessTokenRequest
- type ApiRefreshTokenRequest
- type BaseResponse
- type CampaignDetails
- type CampaignStatus
- type Config
- type DataDetailResponse
- type DetailsDataRequest
- type EncryptedEcpmReq
- type EncryptedEcpmRes
- type Market
- func (c *Market) AuthUrl(scope string) string
- func (m *Market) DecryptEcpms(appId string, encryptedEcpms []string) (*EncryptedEcpmRes, error)
- func (c *Market) Exchange(authorizationCode string) (*TokenResponse, error)
- func (m *Market) GetAccountAdSetsOutline(accountId string, startDate, endDate string, pageSize int) (*AllDataResponse, error)
- func (m *Market) GetAccountsByBusinessId(businessId string, pageSize int) (*AccountResponse, error)
- func (m *Market) GetAllDataByAccountId(req *RequestData, accountId string) (*AllDataResponse, error)
- func (m *Market) GetDetailByDataId(req *RequestData, dataId string) (*DataDetailResponse, error)
- func (m *Market) GetDetailsDataForCountry(outlineItem *AllDataItem, startDate, endDate string, pageSize int) (*DataDetailResponse, error)
- func (m *Market) RefreshToken(clientId string, clientSecret string) (*TokenResponse, error)
- type Paging
- type RequestAccessKes
- type RequestData
- type TokenItem
- type TokenResponse
Constants ¶
View Source
const ( OmniActivateApp = "omni_activate_app" MobileAppInstall = "mobile_app_install" OmniPurchase = "omni_purchase" )
fb actions key
View Source
const ( ApiAccount = "/%s/client_ad_accounts" ApiAccountCampaigns = "/act_%s/campaigns" ApiAccountAdsets = "/act_%s/adsets" ApiAccountAds = "/act_%s/ads" ApiDataDetails = "/%s/insights" ApiRefreshToken = "/oauth/access_token" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Account ¶
type Account struct { Id string `json:"id,optional"` AccountId string `json:"account_id,optional"` Name string `json:"name,optional"` AccountStatus int `json:"account_status,optional"` Balance string `json:"balance,optional"` Currency string `json:"currency,optional"` }
facebook 投放账户信息结构
type AccountResponse ¶
type AccountResponse struct { BaseResponse[[]Account] }
type AllDataItem ¶
type AllDataItem struct { Name string `json:"name,optional"` Status string `json:"status,optional"` EffectiveStatus string `json:"effective_status,optional"` CampaignId string `json:"campaign_id,optional"` AccountId string `json:"account_id,optional"` AdsetId string `json:"adset_id,optional"` Id string `json:"id,optional"` }
简要数据项(冗余:如:获取广告系列数据时 CampaignId,AdsetId 都为空 )
type AllDataResponse ¶
type AllDataResponse struct { BaseResponse[[]AllDataItem] }
type ApiAccessTokenRequest ¶ added in v1.2.118
type ApiRefreshTokenRequest ¶
type BaseResponse ¶
type BaseResponse[T any] struct { Paging struct { Cursors struct { Before string `json:"before,optional"` After string `json:"after,optional"` } `json:"cursors,optional"` Next string `json:"next,optional"` } `json:"paging,optional"` Data T `json:"data,optional"` }
通用返回数据结构
type CampaignDetails ¶
type CampaignDetails struct { AccountId string `json:"account_id,optional"` CampaignId string `json:"campaign_id,optional"` AdsetId string `json:"adset_id,optional"` AdsetName string `json:"adset_name,optional"` AdId string `json:"ad_id,optional"` Impressions string `json:"impressions,optional"` Cpm string `json:"cpm,optional"` Cpc string `json:"cpc,optional"` Spend string `json:"spend,optional"` Clicks string `json:"clicks,optional"` Conversions string `json:"conversions,optional"` Objective string `json:"objective,optional"` CostPerUniqueClick string `json:"cost_per_unique_click,optional"` AccountName string `json:"account_name,optional"` Ctr string `json:"ctr,optional"` DateStart string `json:"date_start,optional"` DateStop string `json:"date_stop,optional"` Country string `json:"country,optional"` Actions []struct { ActionType string `json:"action_type,optional"` Value string `json:"value,optional"` } `json:"actions,optional"` }
func (*CampaignDetails) GetActionStat ¶
func (f *CampaignDetails) GetActionStat(actionType string) int64
type CampaignStatus ¶
type CampaignStatus string
const ( ACTIVE CampaignStatus = "ACTIVE" PAUSED CampaignStatus = "PAUSED" DELETED CampaignStatus = "DELETED" ARCHIVED CampaignStatus = "ARCHIVED" )
type Config ¶ added in v1.2.118
type Config struct { Name string `yaml:"Name" json:"name,optional"` //请求参数 ApiVersion string `yaml:"ApiVersion" json:"apiVersion,optional"` AccessToken string `yaml:"AccessToken" json:"accessToken"` // 授权参数 ClientId string `yaml:"ClientId" json:"clientId"` ClientSecret string `yaml:"ClientSecret" json:"clientSecret"` RedirectUri string `yaml:"RedirectUri" json:"redirectUri"` // contains filtered or unexported fields }
type DataDetailResponse ¶
type DataDetailResponse struct { BaseResponse[[]CampaignDetails] }
type DetailsDataRequest ¶
type DetailsDataRequest struct { RequestData TimeIncrement int `url:"time_increment"` Timezone string `url:"time_zone"` //Asia/Shanghai Breakdowns string `url:"breakdowns"` //['country'] 以国家纬度group by 查询 }
type EncryptedEcpmReq ¶ added in v1.2.119
type EncryptedEcpmReq struct { RequestId string `json:"request_id"` Ecpms []string `json:"ecpms"` AccessToken string `json:"access_token"` SyncApi bool `json:"sync_api"` }
---------meta变现端--------------------------------
type EncryptedEcpmRes ¶ added in v1.2.119
type EncryptedEcpmRes struct { RequestId string `json:"request_id"` Success struct { Value float64 `json:"value"` Accuracy string `json:"accuracy"` } `json:"success"` Error struct { Reason string `json:"reason"` Description string `json:"description"` NoImpressionCount int `json:"no_impression_count"` InvalidImpressionCount int `json:"invalid_impression_count"` } `json:"error"` }
type Market ¶
type Market struct {
Config Config
}
func (*Market) AuthUrl ¶ added in v1.2.118
授权URL
DOC: https://developers.facebook.com/docs/marketing-api/overview/authorization
func (*Market) DecryptEcpms ¶ added in v1.2.119
func (m *Market) DecryptEcpms(appId string, encryptedEcpms []string) (*EncryptedEcpmRes, error)
func (*Market) Exchange ¶ added in v1.2.118
func (c *Market) Exchange(authorizationCode string) (*TokenResponse, error)
获取token
func (*Market) GetAccountAdSetsOutline ¶ added in v1.2.118
func (m *Market) GetAccountAdSetsOutline(accountId string, startDate, endDate string, pageSize int) (*AllDataResponse, error)
概要数据加载,下一页数据 res.Paging.Cursors.After
func (*Market) GetAccountsByBusinessId ¶
func (m *Market) GetAccountsByBusinessId(businessId string, pageSize int) (*AccountResponse, error)
某个商户下所有账号信息 账号余额,状态等等
func (*Market) GetAllDataByAccountId ¶ added in v1.2.118
func (m *Market) GetAllDataByAccountId(req *RequestData, accountId string) (*AllDataResponse, error)
all data -------------------------------
func (*Market) GetDetailByDataId ¶ added in v1.2.118
func (m *Market) GetDetailByDataId(req *RequestData, dataId string) (*DataDetailResponse, error)
根据数据类型获取某个详情,如:广告组详情 广告详情 -------------------------------
func (*Market) GetDetailsDataForCountry ¶ added in v1.2.118
func (m *Market) GetDetailsDataForCountry(outlineItem *AllDataItem, startDate, endDate string, pageSize int) (*DataDetailResponse, error)
某个计划或者广告组所有详情数据以 国家小时为纬度的数据 res.Paging.Cursors.After 通过这个参数重新请求下一页数据
func (*Market) RefreshToken ¶
func (m *Market) RefreshToken(clientId string, clientSecret string) (*TokenResponse, error)
刷新token接口
type RequestAccessKes ¶ added in v1.2.118
type RequestAccessKes struct {
AccessToken string `url:"access_token"`
}
type RequestData ¶
type RequestData struct { Limit int `url:"limit"` //Before string `json:"before"` After string `url:"after"` AccessToken string `url:"access_token"` Fields string `url:"fields"` DateStart string `url:"date_start"` DateStop string `url:"date_stop"` TimeRange string `url:"time_range"` //DateStart And DateStop are here for query TimeIncrement int `url:"time_increment"` // 1表示以天为单位 Timezone string `url:"time_zone"` //日期时区Asia/Shanghai Breakdowns string `url:"breakdowns"` //['country'] 以国家纬度group by 查询 }
type TokenItem ¶
type TokenItem struct { AccessToken string `json:"access_token,optional"` TokenType string `json:"token_type,optional"` ExpiresIn int `json:"expires_in,optional"` Error struct { Message string `json:"message,optional"` Type string `json:"type,optional"` Code int `json:"code,optional"` FbtraceId string `json:"fbtrace_id,optional"` } `json:"error,optional"` }
type TokenResponse ¶
type TokenResponse struct {
TokenItem
}
Click to show internal directories.
Click to hide internal directories.