Documentation ¶
Index ¶
- Constants
- Variables
- func DelClient(names ...string)
- func Init(ctx context.Context, configs ...Config) (err error)
- type Config
- type GoAdmob
- func (c *GoAdmob) AuthUrl() string
- func (c *GoAdmob) Exchange(ctx context.Context, authorizationCode string) (*oauth2.Token, error)
- func (c *GoAdmob) GetAdUnits() (*admob.ListAdUnitsResponse, error)
- func (c *GoAdmob) GetApps() (*admob.ListAppsResponse, error)
- func (c *GoAdmob) GetReport(req *ReportReq) ([]*ResponseItem, error)
- func (o *GoAdmob) Refresh() error
- func (c *GoAdmob) RefreshToken() error
- type ReportReq
- type ResponseItem
Constants ¶
View Source
const ( DefaultCurrencyCode = "USD" DefaultLanguageCode = "en-US" )
View Source
const ( FILTER_APP = "APP" FILTER_COUNTRY = "COUNTRY" FILTER_DATE = "DATE" FILTER_PLATFORM = "PLATFORM" FILTER_AD_UNIT = "AD_UNIT" FILTER_FORMAT = "FORMAT" FILTER_APP_VERSION_NAME = "APP_VERSION_NAME" )
常用纬度
View Source
const ( AD_REQUESTS = "AD_REQUESTS" CLICKS = "CLICKS" ESTIMATED_EARNINGS = "ESTIMATED_EARNINGS" IMPRESSIONS = "IMPRESSIONS" IMPRESSION_CTR = "IMPRESSION_CTR" IMPRESSION_RPM = "IMPRESSION_RPM" MATCHED_REQUESTS = "MATCHED_REQUESTS" MATCH_RATE = "MATCH_RATE" SHOW_RATE = "SHOW_RATE" )
Variables ¶
View Source
var DefaultMetrics = []string{AD_REQUESTS, CLICKS, ESTIMATED_EARNINGS, IMPRESSIONS, IMPRESSION_CTR, IMPRESSION_RPM, MATCHED_REQUESTS, MATCH_RATE, SHOW_RATE}
Functions ¶
Types ¶
type GoAdmob ¶
type GoAdmob struct { Config Config GoAuth *gooauth.GoOAuth AdmobService *admob.Service RequestTimeout int64 //default request timeout 30s // contains filtered or unexported fields }
accessToken 会在60分钟后过期
func (*GoAdmob) AuthUrl ¶
授权admobURL OAuth2.0
1、https://developers.google.com/admob/api/v1/getting-started?hl=zh-cn 创建一个新的授权客户端 获取client_id 和 client_secret
2、浏览器中执行 AuthUrl 方法获取授权code
3、获取code后执行 Exchange 方法获取token
func (*GoAdmob) GetAdUnits ¶
获取当前appId下所有的广告信息
func (*GoAdmob) GetReport ¶
func (c *GoAdmob) GetReport(req *ReportReq) ([]*ResponseItem, error)
dimensions 指定查询维度,如:[]string{"DATE", "APP", "COUNTRY"}
SELECT DATE, APP, COUNTRY, CLICKS, ESTIMATED_EARNINGS FROM NETWORK_REPORT WHERE DATE >= '2021-09-01' AND DATE <= '2021-09-30'
AND COUNTRY IN ('US', 'CN')
GROUP BY DATE, APP, COUNTRY ORDER BY APP ASC, CLICKS DESC;
type ReportReq ¶ added in v1.2.109
type ReportReq struct { Dimensions []string //查询维度列表 AdUnits []string //广告位 Countries []string //国家 AdFormats []string //原生、横幅、插屏、开屏、激励视频 Platforms []string //应用的移动操作系统平台(例如“Android”或“iOS”)。 AppVersionNames []string //对于 Android,应用版本名称可以在 PackageInfo 中的 versionName 中找到。对于 iOS,可以在 CFBundleShortVersionString 中找到应用版本名称。警告:该维度与 ESTIMATED_EARNINGS 和 OBSERVED_ECPM 指标不兼容。 MaxReportRows int64 //最大返回数量 Metrics []string //查询字段、注意:这里的查询字段在不同的纬度下有互斥情况 StartDate admob.Date EndDate admob.Date CurrencyCode string //default currency USD LanguageCode string //default language en-US RetryWaitTime time.Duration RetryCount int }
Click to show internal directories.
Click to hide internal directories.