AdWords API:非MCC账户的客户列表
本文关键字:客户 列表 MCC API AdWords | 更新日期: 2023-09-27 18:29:40
我想获得分配给已验证帐户的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>
我在谷歌上搜索了很多,最终发现我可以为MCC和非MCC帐户使用其他XML(InfoService)。
<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帐户的客户列表?非常感谢。
我也遇到过这个问题,可以确认这不是ServicedAccountService的正确行为;这是一个"未来将解决的已知问题":如果您将基本帐户链接到MCC,则可以使用该基本帐户进行身份验证,并使用ServicedAccountService获取帐户详细信息,但如果该帐户未链接,则会出现此问题。
如果您只想获得帐户的客户id,您也可以使用InfoService,它不会遇到同样的问题。