Difference between revisions of "Web Element: Data"
Line 188: | Line 188: | ||
<button id="authorize-button" style="visibility: hidden">Authorize</button> | <button id="authorize-button" style="visibility: hidden">Authorize</button> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
− | |||
// NOTE: You must replace the client id on the following line. | // NOTE: You must replace the client id on the following line. | ||
var clientId = '549821307845-9ef2xotqflhcqbv10.apps.googleusercontent.com'; | var clientId = '549821307845-9ef2xotqflhcqbv10.apps.googleusercontent.com'; | ||
var scopes = 'https://www.googleapis.com/auth/spreadsheets'; | var scopes = 'https://www.googleapis.com/auth/spreadsheets'; | ||
− | |||
function init() { | function init() { | ||
gapi.auth.authorize( | gapi.auth.authorize( | ||
Line 198: | Line 196: | ||
handleAuthResult); | handleAuthResult); | ||
} | } | ||
− | |||
function handleAuthResult(authResult) { | function handleAuthResult(authResult) { | ||
var authorizeButton = document.getElementById('authorize-button'); | var authorizeButton = document.getElementById('authorize-button'); | ||
Line 209: | Line 206: | ||
} | } | ||
} | } | ||
− | |||
function handleAuthClick(event) { | function handleAuthClick(event) { | ||
gapi.auth.authorize( | gapi.auth.authorize( | ||
Line 216: | Line 212: | ||
return false; | return false; | ||
} | } | ||
− | |||
function makeApiCall() { | function makeApiCall() { | ||
// Note: The below spreadsheet is "Public on the web" and will work | // Note: The below spreadsheet is "Public on the web" and will work | ||
Line 225: | Line 220: | ||
'?tqx=responseHandler:handleTqResponse' + | '?tqx=responseHandler:handleTqResponse' + | ||
'&access_token=' + encodeURIComponent(gapi.auth.getToken().access_token); | '&access_token=' + encodeURIComponent(gapi.auth.getToken().access_token); | ||
− | |||
document.write('<script src="' + tqUrl +'" type="text/javascript"></script>'); | document.write('<script src="' + tqUrl +'" type="text/javascript"></script>'); | ||
} | } | ||
− | |||
function handleTqResponse(resp) { | function handleTqResponse(resp) { | ||
document.write(JSON.stringify(resp)); | document.write(JSON.stringify(resp)); | ||
} | } | ||
− | |||
</script> | </script> | ||
<script src="https://apis.google.com/js/auth.js?onload=init"></script> | <script src="https://apis.google.com/js/auth.js?onload=init"></script> | ||
</body> | </body> | ||
</html> | </html> |
https://docs.google.com/spreadsheets/d/1YUqF27YsO2tVdFL1R6Oxu5BT5itjA_ozZDrekzfFclk/edit?usp=sharing
'); } function handleTqResponse(resp) { document.write(JSON.stringify(resp)); }
hkilter.com by H. K. Ilter is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
© 2020 H. K. Ilter