如何在JavaScript中使用新的Google Ads API

问题描述 投票:0回答:1

是否有关于JavaScript Google Ads实施的文档?我正在寻找gapi的基本用法,例如this example

不再工作:

  • gapi.client.load('https://googleads.googleapis.com/v2/customers')
  • gapi.client.load('https://googleads.googleapis.com/v2/googleAdsFields/ad_group')
  • gapi.client.load('https://content.googleapis.com/discovery/v1/apis/adwords/v2/rest')
  • gapi.client.load('https://content.googleapis.com/discovery/v1/apis/adwords/v2/rest')
  • gapi.client.load('googleads', 'v3')
  • gapi.client.load('adwords', 'v2')
  • gapi.client.load('https://adwords.google.com/api/adwords/cm/v201809/CampaignService')
  • gapi.client.load('https://adwords.google.com/api/adwords/mcm/v201809/AccountLabelService?wsdl')
  • gapi.client.load('https://adwords.google.com/api/adwords/mcm/v201809')

代码:

<script src="https://apis.google.com/js/api.js"></script>
<script>
function authenticate() {
  return gapi.auth2.getAuthInstance()
      .signIn({scope: "https://www.googleapis.com/auth/adwords"})
      .then(function() { console.log("Sign-in successful"); },
            function(err) { console.error("Error signing in", err); });
}
function loadClient() {
  gapi.client.setApiKey("API_KEY");
  return gapi.client.load("https://adwords.google.com/api/adwords/mcm/v201809")
      .then(function() { console.log("GAPI client loaded for API"); },
            function(err) { console.error("Error loading GAPI client for API", err); });
}
function execute() {
  return gapi.client.adwords.accounts.list({})
      .then(function(response) {
              console.log("Response", response);
            },
            function(err) { console.error("Execute error", err); });
}
gapi.load("client:auth2", function() {
  gapi.auth2.init({client_id: "CLIENT_ID"});
});
</script>
<button onclick="authenticate().then(loadClient)">authorize and load</button>
<button onclick="execute()">execute</button>
javascript google-api google-ads-api google-javascript-api
1个回答
0
投票

请参阅Google ADS官方API文档here

它具有您需要的所有相关信息

© www.soinside.com 2019 - 2024. All rights reserved.