$campaignId = 123456789;
$selector = new Selector();
$selector->setFields([
'Id',
'Name',
'Status',
'BudgetId',
]);
$selector->setPredicates([
new Predicate('Id', PredicateOperator::EQUALS, [$campaignId])
]);
这给了我以下结果(我正在使用Laravel):
array:1 [▼
0 => Campaign {#244 ▼
#id: 123456789
#name: "Test campagne"
#status: "PAUSED"
#servingStatus: null
#startDate: null
#endDate: null
#budget: Budget {#241 ▼
#budgetId: 123456789
#name: null
#amount: null
#deliveryMethod: null
#referenceCount: null
#isExplicitlyShared: null
#status: null
}
#conversionOptimizerEligibility: null
#adServingOptimizationStatus: null
#frequencyCap: null
#settings: null
#advertisingChannelType: null
#advertisingChannelSubType: null
#networkSetting: null
#labels: null
#biddingStrategyConfiguration: null
#campaignTrialType: null
#baseCampaignId: null
#forwardCompatibilityMap: null
#trackingUrlTemplate: null
#urlCustomParameters: null
#vanityPharma: null
#selectiveOptimization: null
}
]
当我添加'预算'到setFields数组,发生以下错误
[SelectorError.INVALID_FIELD_NAME @ serviceSelector;触发:'预算']
我是否需要 BudgetService 来检索有关预算的信息?
答案 0 :(得分:1)
选择要在脚本上使用的预算字段。字段名称类似于reports query。
$campaignId = 123456789;
$selector = new Selector();
$selector->setFields([
'Id',
'Name',
'Status',
'BudgetId',
'BudgetName',
'Amount',
'DeliveryMethod',
'BudgetReferenceCount',
'IsBudgetExplicitlyShared',
'BudgetStatus'
]);
$selector->setPredicates([
new Predicate('Id', PredicateOperator::EQUALS, [$campaignId])
]);
答案 1 :(得分:0)
仅是补充先前的回答,我认为您正在寻找错误的方式来获取广告系列预算。如果要获取该统计信息以及其他任何统计信息,则应查看API的reporting
部分。看到以下问题:Getting campaign stats (e.g. Clicks, CTR, CPC, etc.) via AdWords API。
一旦您的报告API正常运行,您应查找的报告为CAMPAIGN_PERFORMANCE_REPORT
:
此后,如果您成功提取了该报告的数据,则应指定Amount
字段(由 @fabrigm 指出)
是的,您可以使用API的服务部分,但是事情变得更加复杂,您必须执行更多的API调用。 API的服务部分更多地用于create/update/delete
,而不是简单的统计信息read
调用。
最后,如果您使用的是API,建议您看一下这些软件包,它们可能会使您的实现更容易: