AdWords API:非MCC帐户的客户列表

时间:2012-03-30 08:44:34

标签: c# xml soap google-adwords

我想获取分配到经过身份验证的帐户的AdWords客户列表(我使用OAuth)。

首次尝试使用ServicedAccountService和此XML请求

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <RequestHeader xmlns="https://adwords.google.com/api/adwords/mcm/v201109">
      <developerToken xmlns="https://adwords.google.com/api/adwords/mcm/v201109">[[DEV_TOKEN]]</developerToken>
    </RequestHeader>
  </soap:Header>
  <soap:Body>
    <get xmlns="https://adwords.google.com/api/adwords/mcm/v201109">
      <selector>
        <enablePaging>false</enablePaging>
      </selector>
    </get>
  </soap:Body>
</soap:Envelope>

但它仅适用于MCC帐户。对于常规谷歌帐户,我有空数据集

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <ResponseHeader xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109" xmlns="https://adwords.google.com/api/adwords/mcm/v201109">
      <ns2:requestId>0004bc71cee633d00aecb0aa000060ca</ns2:requestId>
      <ns2:serviceName>ServicedAccountService</ns2:serviceName>
      <ns2:methodName>get</ns2:methodName>
      <ns2:operations>0</ns2:operations>
      <ns2:responseTime>230</ns2:responseTime>
      <ns2:units>0</ns2:units>
    </ResponseHeader>
  </soap:Header>
  <soap:Body>
    <getResponse xmlns="https://adwords.google.com/api/adwords/mcm/v201109" xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109">
      <rval>
        <accounts>
          <customerId>0</customerId>
          <canManageClients>false</canManageClients>
        </accounts>
      </rval>
    </getResponse>
  </soap:Body>
</soap:Envelope>

我搜索了很多内容,最后found我可以将其他XML(InfoService)用于MCC和非MCC帐户。

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <RequestHeader xmlns="https://adwords.google.com/api/adwords/info/v201109">
      <developerToken xmlns="https://adwords.google.com/api/adwords/cm/v201109">[[DEV_TOKEN]]</developerToken>
    </RequestHeader>
  </soap:Header>
  <soap:Body>
    <get xmlns="https://adwords.google.com/api/adwords/info/v201109">
      <selector>
        <dateRange>
          <min xmlns="https://adwords.google.com/api/adwords/cm/v201109">[[START_DATE]]</min>
          <max xmlns="https://adwords.google.com/api/adwords/cm/v201109">[[END_DATE]]</max>
        </dateRange>
        <includeSubAccounts>true</includeSubAccounts>
        <apiUsageType>UNIT_COUNT_FOR_CLIENTS</apiUsageType>
      </selector>
    </get>
  </soap:Body>
</soap:Envelope>

但返回的数据不正确 - 并未列出所有帐户。或者根本没有返回任何数据。

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
        <ResponseHeader xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109" xmlns="https://adwords.google.com/api/adwords/info/v201109">
            <ns2:requestId>0004bc7121a910e80a97030d000051e7</ns2:requestId>
            <ns2:serviceName>InfoService</ns2:serviceName>
            <ns2:methodName>get</ns2:methodName>
            <ns2:operations>1</ns2:operations>
            <ns2:responseTime>1206</ns2:responseTime>
            <ns2:units>1</ns2:units>
        </ResponseHeader>
    </soap:Header>
    <soap:Body>
        <getResponse xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109" xmlns="https://adwords.google.com/api/adwords/info/v201109">
            <rval>
                <cost>0</cost>
            </rval>
        </getResponse>
    </soap:Body>
</soap:Envelope>

是否有其他方法可以获取AdWords帐户的客户列表?非常感谢。

1 个答案:

答案 0 :(得分:1)

我也遇到过这个问题,并且可以确认它不是ServicedAccountService的正确行为;这是一个"known issue that will be resolved in future":如果您将基本帐户与MCC相关联,那么您可以使用基本帐户进行身份验证并使用ServicedAccountService获取帐户详细信息,但如果该帐户未链接,那么您将获得此信息问题

如果您只想获取帐户的客户ID,您还可以使用InfoService,但不会遇到同样的问题。