在Google Apps脚本中使用Adwords API(MccApp) [英] Use Adwords API (MccApp) in Google Apps Script

查看:72
本文介绍了在Google Apps脚本中使用Adwords API(MccApp)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用GAS(Google Apps脚本)编写的自定义API,并且想从其中使用Adwords API.

I have a custom API written in GAS (Google Apps Script) and would like to utilize the Adwords API from within it.

有时与MccApp一起使用,该服务可从Adwords脚本本身(我的客户中心">脚本")中轻松获得.

Sometimes used along with the MccApp, the service is readily available from within Adwords Scripts itself (My Client Center > Scripts).

例如:

            function account(client) {
              var result = {
                  'id': null,
                  'campaigns': {}
              }
              result.id = client.getCustomerId()
              var currentAct = AdWordsApp.currentAccount()
              MccApp.select(client)
              var campaignIterator = AdWordsApp.campaigns().get()
              while (campaignIterator.hasNext()) {
                  var campaign = campaignIterator.next()
                  result.campaigns[campaign.getName()] = campaign.getId()
              }
              MccApp.select(currentAct)
              return result
            }

但是,此API在Google Apps脚本中尚不可用.我曾尝试在资源>高级Google服务"下以及在开发者控制台下启用它,但是UI没有提供我可以看到的选项.

However, this API is not readily available inside a Google Apps Script. I have tried enabling it under "Resources > Advanced Google Services" and also under the developer console, but the UI offers no option that I can see.

问题:是否可以在Google Apps脚本中启用AdwordsApp和MccApp的使用,以便上述代码段可以在GAS中使用?

QUESTION: Is it possible to enable use of the AdwordsApp and MccApp inside a Google Apps script so that the above code snippet would work in GAS?

如果没有,我已经知道有两种解决方法:

If not, I understand already there are two workarounds:

  1. 只需使用Adwords脚本

  1. Just use Adwords Script

与GAS中的API进行通信,就好像它是外部服务一样(即...使用SOAP,REST等...)

Communicate with the API from GAS as though it were an external service (i.e... using SOAP, REST, etc...)

推荐答案

经过大量研究,实际上没有办法添加MccApp和AdwordsApp服务以在Google Apps脚本中使用.最接近的解决方案是像与API进行外部通信一样,或者仅使用Adwords脚本.

After much research, there really is no way to add the MccApp and AdwordsApp services for use in a Google Apps script. The nearest solution is to communicate with the API as though it were external or just use an Adwords Script.

这篇关于在Google Apps脚本中使用Adwords API(MccApp)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆