您的位置:首页 > 编程语言 > Go语言

GoogleAPI-Adwords-Bid Landscapes

2016-01-28 16:52 357 查看


Bid Landscapes 类似于  bid
simulators in the AdWords user interface

bid simulator: 模拟出价。

要求:
已经建立了广告或criterion 
Conversion Tracking must be enabled.
必须用正式账号,不能用测试账号,因为这是基于以前的正式数据。

实现:
1.设置fields, fetch或get数据

DataServiceInterface dataService =
    adWordsServices.get(session, DataServiceInterface.class);
Selector selector = new SelectorBuilder()
    .fields(
        "AdGroupId",
        "CriterionId",
        "StartDate",
        "EndDate",
        "Bid",
        "LocalClicks",
        "LocalCost",
        "LocalImpressions") // Include whichever fields interest you
    .equals("AdGroupId", adGroupId.toString())
    .build();
CriterionBidLandscapePage page = dataService.getCriterionBidLandscape(selector);


2.分页

selector.getPaging().setNumberResults(PAGE_SIZE); // Set to your desired
                                                  // page size.
int landscapePointsInLastResponse = 0;
int offset = 0;
do {
  // Offset by the number of landscape points, NOT the number
  // of entries (bid landscapes) in the last response.
  offset += landscapePointsInLastResponse;
  selector.getPaging().setStartIndex(offset);
  landscapePointsInLastResponse = 0;
  CriterionBidLandscapePage page = dataService
    .getCriterionBidLandscape(selector);
  if (page.getEntries() != null) {
    for (CriterionBidLandscape bidLandscape : page.getEntries()) {
      for (BidLandscapeLandscapePoint landscapePoint : bidLandscape
        .getLandscapePoints()) {
        // Process results...
        landscapePointsInLastResponse++;
      }
    }
  }
} while (landscapePointsInLastResponse >= PAGE_SIZE);


结果

<landscapePoints>
  <bid>
    <ComparableValue.Type>Money</ComparableValue.Type>
    <microAmount>990000</microAmount>
  </bid>
  <clicks>278000</clicks>
  <cost>
    <ComparableValue.Type>Money</ComparableValue.Type>
    <microAmount>14500000000</microAmount>
  </cost>
  <impressions>648000</impressions>
  <promotedImpressions>0</promotedImpressions>
</landscapePoints>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: