是否有关于JavaScript Google Ads实施的文档?我正在寻找this example上的gapi
的基本用法
不再工作:
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>