Upload
martin-hawksey
View
1.596
Download
2
Embed Size (px)
Citation preview
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
CC-BY-NC-ND lukexmartin https://flic.kr/p/9dL4vY
CC-BY-NC Xtream_i https://flic.kr/p/tYTwd
JavaScript in the cloud
Apps Script is based on JavaScript 1.6, plus a few features from 1.7 and 1.8.
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???
Where..
StandaloneSheets DocsForms Sites
Integration
CC-BY-NC Eugen Stollhttps://flic.kr/p/5c6ce
One liners
One liners
One liners
One liners{ish}
Toast
Custom UI
CC-BY Google Inc. Apps Script Menus
Auth
One liners services
CalendarContactsDocumentDriveFormsGmail
GroupsLanguageMapsSitesSpreadsheet
One{ish} liners services
AdSenseAnalyticsApps ActivityBigQueryCalendarClassroomDriveDoubleClick CampaignsFusion Tables
GmailGoogle+Google+ DomainsMirrorPredictionShopping ContentTasksURL ShortenerYouTube
Advanced Services
…fetch
BY-NC-SA tartemehttps://flic.kr/p/bAoEyi
“…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.
Comparing CiviEvent
registrations for annual events
and automatically reporting on a
daily basis
Problem
CiviReport
“Scheduled Jobs - Mail Reports (mail_report)
27
Triggers
Trigger
// set the script to read the email run 15min later ScriptApp.newTrigger("processInbox") .timeBased() .after(15 * 60 * 1000) .create();
Hello Libraries
Libraries
https://plus.google.com/+SpencerEastonCCS/posts/hrQ9eaHMUW6
Identity
CC-BY-NC Thomas Hawk https://flic.kr/p/bUy6wK
Google Apps Script Web apps
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 >
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 >
HtmlService
HtmlService
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 >
“ContentService
ContentService supports returning TEXT, ATOM, CSV, iCal, JavaScript,
JSON, RSS, vCard, and XML
“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
“Properties Service
store simple data in key-value pairs scoped to one script, one user of a script,
or one document
getScriptProperties()getUserProperties()
getDocumentProperties()
Let's play…
CC-BY-NC-ND Elke Noda https://flic.kr/p/58zapN
https://tags.hawksey.info/
TAGS Summary
TAGSExplorer
TwtrService
Advanced Services
Google Analytics
Google Analytics
[demo link]
Google Analytics
Twitter referral mashed with Google Analytics
Translation
Maps
Google Add-ons
CC-BY gail heidel https://flic.kr/p/65aFCx
Add-ons in action
Domain distribution
Community
Danke!
+MartinHawksey@mhawkseyEdTech Explorermashe.hawksey.info
http://go.alt.ac.uk/GDGBerlin-AppsScript