显示带有标签的帖子 乔's Airport Motel. 显示所有帖子
显示带有标签的帖子 乔's Airport Motel. 显示所有帖子

2013年3月10日,星期日

根据机场延误管理广告

如今,互联网上有大量的API。这些中的任何一个都可以合并到您的AdWords辽宁福利彩票中心中,以自动化一些帐户管理。

以下辽宁福利彩票中心使用 FAA.gov提供的机场状态服务 在主要机场出现延误时启用和暂停广告。这对于机场附近可能从航班延误中受益的任何企业(例如餐厅,酒吧或酒店)很有用。您的广告可能会说:



您可以从顶部的列表中添加或删除机场代码。您需要做的只是用[airport_code] _delay标签(“ ORD_delay”,“ ATL_delay”)标记广告。

您还可以使用其他哪些动态数据来优化广告?电影时间?体育游戏?在下面的评论中让我知道,然后我会提出我的建议。

谢谢,
拉斯

/*********************************************
* Pause/Enable Ads Based On Airport Delays
* Version 1.1
* ChangeLog v1.1 
*  - Added ability to completely 暂停 non-delay 广告
* Created By: 拉斯 Savage
* FreeAdWordsScripts.com
*********************************************/
// For this to work, you need to 广告 d a 标签 to all
// the 广告 for each 飞机场.  For example, PIT_normal
// or SFO_normal
var PAUSE_NORMAL_ADS_DURING_DELAY = false;
var DELAY_SUFFIX = '_delay'; //the suffix on the 标签 for delayed 广告
var NORMAL_SUFFIX = '_normal'; //the suffix on the 标签 for normal 广告

var AIR_CODES = ["ATL","ANC","AUS","BWI","BOS","CLT","MDW","ORD","CVG","CLE",
                 "CMH","DFW","DEN","DTW","FLL","RSW","BDL","HNL","IAH","HOU",
                 "IND","MCI","LAS","LAX","MEM","MIA","MSP","BNA","MSY","JFK",
                 "LGA","EWR","OAK","ONT","MCO","PHL","PHX","PIT","PDX","RDU",
                 "SMF","SLC","SAT","SAN","SFO","SJC","SNA","SEA","STL","TPA",
                 "IAD","DCA"];

function main() {
  var faaUrl = "http://services.faa.gov/airport/status/";
  var args = "?format=application/json";
  for(var i in AIR_CODES) {
    try{
      var resp = UrlFetchApp.fetch(faaUrl + AIR_CODES[i] + args);
      if( resp.getResponseCode() == 200 ) {
        var json = Utilities.jsonParse(resp.getContentText());
        if(json.delay == "false") {
          Logger.log("No 延误 在 "+json.IATA+". Pausing delay 广告 if any are running.");
          turnOffDelayAds(json.IATA);
          if(PAUSE_NORMAL_ADS_DURING_DELAY) {
            turnOnNonDelayAds(json.IATA);
          }
        } else {
          Logger.log("Delays in "+json.IATA+" Reason: "+json.status.reason);
          Logger.log("Turning on delay 广告 if there are any.");
          turnOnDelayAds(json.IATA);
          if(PAUSE_NORMAL_ADS_DURING_DELAY) {
            turnOffNonDelayAds(json.IATA);
          }
        }
      }
    }
    catch(e) {
      Logger.log("Error: " + e.message);
    }
  }
}

function turnOffDelayAds(airportCode) {
  var 标签Name = 飞机场Code + DELAY_SUFFIX;
  var 广告 Iter = AdWordsApp.ads()
    .withCondition("LabelNames CONTAINS_ANY ['"+labelName+"']")
    .withCondition("CampaignStatus = ENABLED")
    .withCondition("AdGroupStatus = ENABLED")
    .withCondition("Status = ENABLED")
    .get();
  while(adIter.hasNext()) {
    广告 Iter.next().pause();
  }
}

function turnOffNonDelayAds(airportCode) {
  var 标签Name = 飞机场Code + NORMAL_SUFFIX;
  var 广告 Iter = AdWordsApp.ads()
    .withCondition("LabelNames CONTAINS_ANY ['"+labelName+"']")
    .withCondition("CampaignStatus = ENABLED")
    .withCondition("AdGroupStatus = ENABLED")
    .withCondition("Status = ENABLED")
    .get();
  while(adIter.hasNext()) {
    广告 Iter.next().pause();
  }
}

function turnOnDelayAds(airportCode) {
  var 标签Name = 飞机场Code + DELAY_SUFFIX;
  var 广告 Iter = AdWordsApp.ads()
    .withCondition("LabelNames CONTAINS_ANY ['"+labelName+"']")
    .withCondition("CampaignStatus = ENABLED")
    .withCondition("AdGroupStatus = ENABLED")
    .withCondition("Status = PAUSED")
    .get();
  while(adIter.hasNext()) {
    广告 Iter.next().enable();
  }
}

function turnOnNonDelayAds(airportCode) {
  var 标签Name = 飞机场Code + NORMAL_SUFFIX;
  var 广告 Iter = AdWordsApp.ads()
    .withCondition("LabelNames CONTAINS_ANY ['"+labelName+"']")
    .withCondition("CampaignStatus = ENABLED")
    .withCondition("AdGroupStatus = ENABLED")
    .withCondition("Status = PAUSED")
    .get();
  while(adIter.hasNext()) {
    广告 Iter.next().enable();
  }
}