0
我試圖從https://developers.google.com/adwords/scripts/docs/tutorials/countdown-sale的AdWords倒計時腳本的廣告羣組錯誤
腳本執行倒計時腳本適用於單一的廣告組,但嘗試增加廣告組的一部分時,我不斷收到以下錯誤:
TypeError:無法調用未定義的方法「setAdParam」。 (9號線)
我完整的腳本:
// Date to use to find out how many days are remaining.
var END_DATE = new Date('February 24, 2013');
// Change this to the Ad Group you set up with text ads with AdParams.
var AD_GROUP_NAMES = ['AdGroup1', AdGroup2'];
function main() {
var timeLeft = calculateTimeLeftUntil(END_DATE);
var adGroups = getAdGroups(AD_GROUP_NAMES);
while (adGroups.hasNext()) {
var adGroup = adGroups.next();
var keywords = adGroup.keywords().get();
// We want to update {param1} to use our calculated days and {param2} for hours.
keywords.setAdParam(1, timeLeft['days']); // HERE COMES THE ERROR
keywords.setAdParam(2, timeLeft['hours']);
}
}
var DAY_IN_MILLISECONDS = 1000*60*60*24;
function calculateTimeLeftUntil(end) {
var current = new Date();
var timeLeft = {};
var daysFloat = (end - current)/(DAY_IN_MILLISECONDS);
timeLeft['days'] = Math.floor(daysFloat);
timeLeft['hours'] = Math.floor(24 * (daysFloat - timeLeft['days']));
return timeLeft;
}
function getAdGroups(names) {
var predicateValues = "['" + names.join("','") + "']";
Logger.log(predicateValues);
return AdWordsApp.adGroups()
.withCondition('Name IN ' + predicateValues)
.withLimit(names.length)
.get();
}