Skip to content
View bloggerAPIExample.gs
var CLIENT_ID = 'YOUR_CLIENT_ID';
var CLIENT_SECRET = 'YOUR_CLIENT_SECRET';
function getService() {
// Create a new service with the given name. The name will be used when
// persisting the authorized token, so ensure it is unique within the
// scope of the property store.
return OAuth2.createService('blogger')
// Set the endpoint URLs, which are the same for all Google services.
View code.gs
var DOC_ID = '1K5IJLwK7qBUfLAG-tic9hOK3L8x4qUIQgd3gryHNE6Y';
function doGet() {
var doc =SpreadsheetApp.openById(DOC_ID);
var auth_user = doc.getViewers();
var auth = auth_user.map(function(user) {
return String(user);
});
var user = Session.getActiveUser().getEmail();
if (auth.indexOf(user) > -1){
View code.gs
// LICENSES http://www.apache.org/licenses/LICENSE-2.0
var DOC_ID = '<INSERT_SPREADSHEET_DOC_ID>';
var SHEET_NAME = 'Sheet1';
/**
* Add a row of data to a sheet.
* @param {Object} parameters passed from script.
* @return {Object} result.
*/
function setData(parameters) {
View quickstart.html
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<title>Google Sheets as a Database – Authenticated INSERT with Apps Script using Execution API - Working Example</title>
<script type="text/javascript">
// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
var CLIENT_ID = '<INSERT_YOUR_CLIENT_ID>';
var SCRIPT_ID = '<INSERT_YOUR_SCRIPT_ID>';
View emailchart.gs
// Modified from http://stackoverflow.com/a/22200230/1027723
function emailCharts(sheet,emails,emailSubject){
var charts = sheet.getCharts();
if(charts.length==0){
MailApp.sendEmail({
to: emails,
subject: "ERROR:"+emailSubject,
htmlBody: "No charts in the spreadsheet"});
return;
View importioAuthExample.gs
function getResults() {
var connector = {'username':'YOUR_SITE_USERNAME',
'password':'YOUR_SITE_PASSWORD',
'connectorDomain':'YOUR_CONNECTOR_DOMAIN',
'userGuid':'YOUR_USER_GUID',
'connectorGuid':'YOUR_CONNECTOR_GUID',
'apiKey':'YOUR_API_KEY'}
var creds = {};
creds[connector.connectorDomain] = {
View code.js
// Copyright 2015 Martin Hawksey. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
View OpenBadgesSender.js
var BASE_URL = 'https://sites.google.com/a/hawksey.info/sandbox/mozilla-open-badges-issuer-example'; // Google Sites page
// for script to handle issuing badges see https://script.google.com/d/1wOxT8VA2mhPVR4b4v7jMTOiIa3hNkUJyAcHUzUh6sObSITyOu3wKi4NS/edit?usp=sharing
/**
* Handle form submit
*/
function onSubmit(e) {
var doc = SpreadsheetApp.getActiveSpreadsheet();
var sheet = doc.getSheetByName("IssuedBadges"); // note: assumed sheet name
var email = e.namedValues['Email'][0]; // note: assumed question name with person's email address
var uid = getUID();
View gist:258608abc8f3286e9ba5
{
"recipient":{
"type":"email",
"hashed":true,
"salt":"MASHeHawk53yBl0g",
"identity":"sha256$7da5d01955b57cdefd04994e98e68541e4f1c9f99ac3308d5f14485c60ac0e8f"
},
"image":"https://dl.dropboxusercontent.com/u/7860124/ALT-Survey-Badge-2014.png",
"badge":"https://script.google.com/macros/s/AKfycbx5uvVcmmHweZwhIxzO0IAUrUtY_cW88Sz1B-MpquZxopvfyIY/exec?type=badge",
"verify":{
View code
function sendEmail(e) {
var emailTo = e.namedValues['20. Email confirmation (and badge)'][0];
if (emailTo != ""){
var text = 'Thank you for taking time to complete the ALT Annual Survey 2014. You can help us get a better understanding of how learning technology is used across sectors by sharing this link to the survey with your community: http://go.alt.ac.uk/ALT-Survey-2014\n\nYou might also use this suggested text in a tweet:\n\n " Just completed the ALT Annual Survey 2014 exploring use of learning technology across sectors. Have your say http://go.alt.ac.uk/ALT-Survey-2014 #altc "';
var textHtml = HtmlService.createHtmlOutputFromFile('mailText').getContent();
MailApp.sendEmail(emailTo,
"Thank you for completing the ALT Annual Survey 2014",
text,
{replyTo:"enquiries@alt.ac.uk", htmlBody: textHtml});
}
Something went wrong with that request. Please try again.