我正在使用Bing Ads脚本。不幸的是,Microsoft不存在对Bing Ads脚本的支持。我的问题是,在第24行出现此错误:
错误::方法“ Budget.setAmount”的参数“ amount”无效。预期的类型为Number,但主要使用Array(脚本代码:24:1)
function main(){
var bingClientsRaw = '[{"AccountId": HIDDEN,"campaignName": "HIDDEN","budgetValue": 0.01},{"AccountId": HIDDEN,"campaignName": "HIDDEN","budgetValue": 0.02},{"AccountId": HIDDEN,"campaignName": "HIDDEN","budgetValue": 0.03}]';
var bingClients = JSON.parse(bingClientsRaw);
for (var i = 0; i < bingClientsRaw.length; i++){
var accounts = AccountsApp.accounts()
.withIds(bingClients.map(a=>a.AccountId).map(String))
.get();
var account = accounts.next();
AccountsApp.select(account);
var iterator = AdsApp.budgets()
//.campaigns() // TypeError: Object doesn't support property or method 'campaigns' Ignore.
.get();
var budget = iterator.next();
var newBudget = bingClients.map(c=>c.budgetValue).map(Number);
budget.campaigns();
budget.setAmount(newBudget);
Logger.log(`${budget.getName()} | Shared?: ${budget.isExplicitlyShared()} | New Budget: ${newBudget}`);
}
}
此代码应在for (){}
循环中运行,为每个帐户/广告系列(accountId
,campaignName
和budgetValue
)获取前3个唯一值,并更新其预算,然后移至后三个值-更新它们,依此类推。相反,它看到的是数组而不是单个值,因此无法继续。谢谢。