google-apps-script
Kunden ringer till Google apps-script
Sök…
Introduktion
Google-appscript fungerar bra som en fristående plattform och i tilläggsformatet för Google-dokument, ark och formulär. Det finns dock tillfällen då en klientwebbläsare kan behöva ringa till en Google-app för att utföra vissa åtgärder.
Därför introducerade Google klientsidesförfrågningar till Google-apps-skript. För att lösa detta problem introducerade Google klientsidobiblioteken
Detta är ett exempel på ett klientsidesamtal till ett Google-app-skript
<script src="https://apis.google.com/js/api.js"></script>
<script>
function start() {
// 2. Initialize the JavaScript client library.
gapi.client.init({
'apiKey': 'YOUR_API_KEY',
// clientId and scope are optional if auth is not required.
'clientId': 'YOUR_WEB_CLIENT_ID.apps.googleusercontent.com',
'scope': 'profile',
}).then(function() {
// 3. Initialize and make the API request.
return gapi.client.request({
'path': 'https://people.googleapis.com/v1/people/me',
})
}).then(function(response) {
console.log(response.result);
}, function(reason) {
console.log('Error: ' + reason.result.error.message);
});
};
// 1. Load the JavaScript client library.
gapi.load('client', start);
</script>
Modified text is an extract of the original Stack Overflow Documentation
Licensierat under CC BY-SA 3.0
Inte anslutet till Stack Overflow