google apps script: the authentic{ated} playground [2015 ed.]

61
This work is licensed under a Creative Commons Attri bution 4.0 Unported Li cense . CC-BY mhawksey Google Apps Script: +Martin Hawksey @mhawksey The authentic{ated} playground http://go.alt.ac.uk/GDGBerlin- AppsScript

Upload: martin-hawksey

Post on 11-Jan-2017

1.596 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Google Apps Script: The authentic{ated} playground [2015 Ed.]

This work is licensed under a

Creative Commons Attribution 4.0 Unported License

. CC-BY mhawksey

Google Apps Script:

+Martin Hawksey@mhawksey

The authentic{ated} playground

http://go.alt.ac.uk/GDGBerlin-AppsScript

Page 2: Google Apps Script: The authentic{ated} playground [2015 Ed.]
Page 3: Google Apps Script: The authentic{ated} playground [2015 Ed.]

CC-BY-NC-ND lukexmartin https://flic.kr/p/9dL4vY

Page 4: Google Apps Script: The authentic{ated} playground [2015 Ed.]

CC-BY-NC Xtream_i https://flic.kr/p/tYTwd

Page 5: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Google Apps Script

CC-BY Google – Google Apps Script, 13-03-2012

Page 6: Google Apps Script: The authentic{ated} playground [2015 Ed.]

JavaScript in the cloud

Apps Script is based on JavaScript 1.6, plus a few features from 1.7 and 1.8.

Page 7: Google Apps Script: The authentic{ated} playground [2015 Ed.]

A brief history

2009Scripts in SheetsCustom functions

2010UiApp*Web Apps (run as developer)Script Gallery*

2011Scripts in SitesGUI Builder*More services

2012Standalone scriptsHTMLSerivceScriptDb*Web Apps (run as user)Libraries and versioningContent ServiceChrome Web Store

2013Scripts in DocScripts in FormsAuth flowMore services

2014Add-on for Documents, Sheets and FormsIFRAME for HTMLService

* Denotes deprecated services/features

Adapted from Wesley Chun’s Google Apps Script

2015Execution API

2016???

Page 8: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Where..

StandaloneSheets DocsForms Sites

Page 9: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Integration

CC-BY-NC Eugen Stollhttps://flic.kr/p/5c6ce

Page 10: Google Apps Script: The authentic{ated} playground [2015 Ed.]

One liners

Page 11: Google Apps Script: The authentic{ated} playground [2015 Ed.]

One liners

Page 12: Google Apps Script: The authentic{ated} playground [2015 Ed.]

One liners

Page 13: Google Apps Script: The authentic{ated} playground [2015 Ed.]

One liners{ish}

Page 14: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Toast

Page 15: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Custom UI

CC-BY Google Inc. Apps Script Menus

Page 16: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Auth

Page 17: Google Apps Script: The authentic{ated} playground [2015 Ed.]

One liners services

CalendarContactsDocumentDriveFormsGmail

GroupsLanguageMapsSitesSpreadsheet

Page 18: Google Apps Script: The authentic{ated} playground [2015 Ed.]

One{ish} liners services

AdSenseAnalyticsApps ActivityBigQueryCalendarClassroomDriveDoubleClick CampaignsFusion Tables

GmailGoogle+Google+ DomainsMirrorPredictionShopping ContentTasksURL ShortenerYouTube

Page 19: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Advanced Services

Page 20: Google Apps Script: The authentic{ated} playground [2015 Ed.]

…fetch

BY-NC-SA tartemehttps://flic.kr/p/bAoEyi

Page 21: Google Apps Script: The authentic{ated} playground [2015 Ed.]

“…fetch

UrlFetchApp.fetch(url, params);

This service allows scripts to access other resources on the web by fetching URLs. A script can use the UrlFetch service to issue HTTP and HTTPS requests

and receive responses. The UrlFetch service uses Google's network infrastructure for

efficiency and scaling purposes.

Page 22: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Comparing CiviEvent

registrations for annual events

and automatically reporting on a

daily basis

Problem

Page 23: Google Apps Script: The authentic{ated} playground [2015 Ed.]
Page 24: Google Apps Script: The authentic{ated} playground [2015 Ed.]

CiviReport

Page 25: Google Apps Script: The authentic{ated} playground [2015 Ed.]

“Scheduled Jobs - Mail Reports (mail_report)

Page 26: Google Apps Script: The authentic{ated} playground [2015 Ed.]
Page 27: Google Apps Script: The authentic{ated} playground [2015 Ed.]

27

Page 28: Google Apps Script: The authentic{ated} playground [2015 Ed.]
Page 29: Google Apps Script: The authentic{ated} playground [2015 Ed.]
Page 30: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Triggers

Page 31: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Trigger

// set the script to read the email run 15min later ScriptApp.newTrigger("processInbox") .timeBased() .after(15 * 60 * 1000) .create();

Page 32: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Hello Libraries

Page 33: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Libraries

https://plus.google.com/+SpencerEastonCCS/posts/hrQ9eaHMUW6

Page 34: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Identity

CC-BY-NC Thomas Hawk https://flic.kr/p/bUy6wK

Page 35: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Google Apps Script Web apps

Page 36: Google Apps Script: The authentic{ated} playground [2015 Ed.]

HtmlService: Templating

function doGet() { return HtmlService .createTemplateFromFile('Index') .evaluate() .setSandboxMode(HtmlService.SandboxMode.IFRAME);}

CODE.GS

<!DOCTYPE html><html> <head> <base target="_top"> </head> <body> Hello, World! The time is <?= new Date() ?>. </body></html>

INDEX.HTML

< CC-BY Google >

Page 37: Google Apps Script: The authentic{ated} playground [2015 Ed.]

HtmlService: Communicate with Server

function doGet() { return HtmlService.createHtmlOutputFromFile('Index') .setSandboxMode(HtmlService.SandboxMode.IFRAME);}

function doSomething() { Logger.log('I was called!');}

CODE.GS

<!DOCTYPE html><html> <head> <base target="_top"> <script> google.script.run.doSomething(); </script> </head></html>

INDEX.HTML

< CC-BY Google >

Page 38: Google Apps Script: The authentic{ated} playground [2015 Ed.]

HtmlService

Page 39: Google Apps Script: The authentic{ated} playground [2015 Ed.]

HtmlService

Page 40: Google Apps Script: The authentic{ated} playground [2015 Ed.]

ContentService

function doGet() { return ContentService.createTextOutput('Hello, world!');}

function doGet(request) { var events = CalendarApp.getEvents( new Date(Number(request.parameters.start) * 1000), new Date(Number(request.parameters.end) * 1000)); var result = { available: events.length == 0 }; return ContentService.createTextOutput( request.parameters.prefix + '(' + JSON.stringify(result) + ')') .setMimeType(ContentService.MimeType.JAVASCRIPT);}

JSONP

TXT

< CC-BY Google >

Page 41: Google Apps Script: The authentic{ated} playground [2015 Ed.]

“ContentService

ContentService supports returning TEXT, ATOM, CSV, iCal, JavaScript,

JSON, RSS, vCard, and XML

Page 42: Google Apps Script: The authentic{ated} playground [2015 Ed.]

“Execution API

The Apps Script Execution API is a REST interface that lets a third-party

application call a function defined in an Apps Script project and receive a

response. This API lets you expose the full utility of Apps Script to any application,

including Android and iOS apps....can be used with Google APIs Client Libraries

Page 44: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Let's play…

CC-BY-NC-ND Elke Noda https://flic.kr/p/58zapN

Page 45: Google Apps Script: The authentic{ated} playground [2015 Ed.]

https://tags.hawksey.info/

Page 46: Google Apps Script: The authentic{ated} playground [2015 Ed.]

TAGS Summary

Page 47: Google Apps Script: The authentic{ated} playground [2015 Ed.]

TAGSExplorer

Page 48: Google Apps Script: The authentic{ated} playground [2015 Ed.]

TwtrService

Page 50: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Advanced Services

Page 51: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Google Analytics

Page 52: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Google Analytics

Page 54: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Twitter referral mashed with Google Analytics

Page 55: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Translation

Page 56: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Maps

Page 57: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Google Add-ons

CC-BY gail heidel https://flic.kr/p/65aFCx

Page 58: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Add-ons in action

Page 59: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Domain distribution

Page 60: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Community

Page 61: Google Apps Script: The authentic{ated} playground [2015 Ed.]

Danke!

+MartinHawksey@mhawkseyEdTech Explorermashe.hawksey.info

http://go.alt.ac.uk/GDGBerlin-AppsScript