SlideShare una empresa de Scribd logo
1 de 44
Descargar para leer sin conexión
Google
Apps Script
Introduction
https://www.facebook.com/groups/GCPUG.TW/
https://plus.google.com/u/0/communities/116100913832589966421
Google Cloud Platform User Group Taiwan
我們是Google Cloud Platform Taiwan User Group。在Google雲端服務在台灣地區展露頭角之後,
有許多新的服務、新的知識、新的創意,歡迎大家一起分享,一起了解 Google雲端服務...
GCPUG透過網際網路串聯喜好 Google Cloud的使用者,分享與交流使用 GCP的點滴鑑驗。如果您
是Google Cloud Platform的初學者,您應該來聽聽前輩們的使用經驗;如果您是 Google Cloud
Platform的Expert,您應該來分享一下寶貴的經驗,並與更多高手互相交流;如果您還沒開始用
Google Cloud Platform,那麼您應該馬上來聽聽我們是怎麼使用 Google Cloud的!
Hello!
I am Cage Chung
I am here because I like
to share my
experiences.
You can find me at:
http://kaichu.io
Outline
◎ What’s Google Apps Script?
◎ Case study - Orgtree chrome extension
◎ Google Apps Script for Mobile developers
◎ Tips & Study information
1.
What’s Google App
Scripts
Let’s start with the first set of slides
“
Google Apps Script is a scripting
language based on JavaScript
that lets you do new and cool
things with Google Apps
Where
Google apps, 1 platform in the cloud
Add-ons for Google Apps
Google Sheets, Docs, and Forms
Add-ons run inside Google Sheets, Docs, and Forms
Add-ons for Google Apps - continue
Google Service
◎ Calendar
◎ Contacts
◎ Documents
◎ Domain Deprecated
◎ Drive
◎ Forms
◎ Gmail
◎ Groups
◎ Language
◎ Maps
◎ Sites
◎ Spreadsheet
Advances Google Service
◎ Admin SDK
◎ AdSense
◎ Analytics
◎ App Activity
◎ BigQuery
◎ Calendar
◎ Classroom
◎ Drive
◎ DoubleClick
Campaigns
◎ Fusion Table
◎ Gmail
◎ Google+
◎ Google+ Domains
◎ Mirror
◎ Prediction
◎ Shopping Content
◎ Tasks
◎ URL Shortener
◎ YouTube
Type of Scripts - Standalone
Standalone
is any script that is not bound to a Google Sheets, Docs, or Forms file
or Google Sites.
// Log the name of every file in the user's Drive that modified after February 28,
// 2013 whose name contains "untitled".
function doAction(){
var files = DriveApp.searchFiles(
'modifiedDate > "2015-01-01" and title contains "untitled"');
while (files.hasNext()) {
var file = files.next();
Logger.log(file.getName());
}
}
[iOS Taipei - Apps Script - Type of Scripts - Standalone](https://goo.gl/oj8WVO)
Bound to Google Apps
A script is bound to a Google Sheets, Docs, or Forms file.
Type of Scripts - Bound to Google Apps
function doAction(range) {
// Get the active spreadsheet and the active sheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
// Get the range of cells that store employee data.
var libraryDataRange = sheet.getRange(range);
var libraryObjects = getRowsData(sheet, libraryDataRange, 1);
libraryObjects.forEach(function (row, index) {
var latlng = getLatitudeLongitude(row.address)
if (latlng) {
sheet.getRange(index + 2, 5, 1, 1).setValue(latlng.lat);
sheet.getRange(index + 2, 6, 1, 1).setValue(latlng.lng);
}
});
}
Type of Scripts - Bound to Google Apps. continue
[coffeemap-testing-form - Google Sheets](https://goo.gl/ZAIOtT)
[coffeemap](https://goo.gl/Wb91tW) quick setup form
[Coffee Stores Map](https://goo.gl/Wg6mWu)
Trigger and Events
Triggers let Apps Script run a function automatically when a certain
event, like opening a document, occurs.
Web Apps and Site Gadgets
If you build a user interface for a script, you can publish the script as a
web app.
◎ It contains a doGet(e) and doPost(e) function.
◎ The function returns an HTML service HtmlOutput object or
a Content service TextOutput object.
Type of Scripts - Web Apps and Site Gadgets
Type of Scripts - Web Apps and Site Gadgets. continue
function doGet() {
var ss = SpreadsheetApp.openById('1QgsaX4Vn_lIwLFRC_iHs6gmJYIP4y-35nVqQOpz4B0s');
var sheet = ss.getSheets()[0];
// Get the range of cells that store employee data.
var employeeDataRange = ss.getRangeByName("employeeData");
// For every row of employee data, generate an employee object.
var employeeObjects = getRowsData(sheet, employeeDataRange);
return ContentService.createTextOutput(JSON.stringify(employeeObjects)).setMimeType(ContentService.
MimeType.JSON);
}
...
[iOS Taipei - employee Data](https://goo.gl/NpdIrQ)
$ curl -L https://script.google.com/macros/s/AKfycbz4Z2dm-MUidB98H5XbekL0LZnvPVRM3ekpG-NSrScc9tvI87A/exec
[{"level":1,"id":"A00","parent":"root","type":"D","title":"資訊研發處","email":"A00@aa.bb.cc"},{"level":2,"
id":"A10","parent":"A00","type":"D","title":"資訊研發部","email":"A10@aa.bb.cc"},{"level":3,"id":"SunnyHu","
parent":"A10","type":"U","title":"胡適 ...
2.
Case Study -
Orgtree Chrome
extension
Let’s start with the second set of
slides
Big
concept
Insert your own
organization contacts
to Gmail and Drive with
ease
Place your screenshot here
Orgtree chrome extension - Gmail
Place your screenshot here
Orgtree chrome extension - Drive
Place your screenshot here
Orgtree chrome extension - Pick
Spreadsheet
Orgtree architecture
Google Apps Script Execution API
Orgtree Chrome extension
Spreadsheet
orgtree-example-data
Level ID Parent Type * Title Email
1 A00 root D 資訊研發處 A00@aa.bb.cc
2 A10 A00 D 資訊研發部 A10@aa.bb.cc
3 SunnyHu A10 U 胡適 hushi@aa.bb.cc
3 SimonSu A10 U 蘇武 suwu@aa.bb.cc
2 EthanChang A00 U 張三 zhangshang@aa.bb.cc
1 B00 root D 技術支援處 B00@aa.bb.cc
2 BensonChen B00 U 陳班森 bensonchen@aa.bb.cc
[orgtree - sheet 2 json](https://goo.gl/WmaHmG)
Apps Script
function getSheetJSON(sheetId) {
var ss = SpreadsheetApp.openById(sheetId);
var sheets = ss.getSheets();
var json = sheets.map(function(sheet) {
return convertSheet2JsonText(sheet);
});
return JSON.stringify(json);
}
function convertSheet2JsonText(sheet) {
// read spreadsheet value to array
...
return jsonArray;
}
Apps Script - continue
◎ Files/Project properties/scopes - https://www.
googleapis.com/auth/spreadsheets
◎ Resources/Developers Console Project -
Link Google Console Project
○ Google Apps Script Execution API - Register OAuth
2.0 client IDs required.
Google Apps Script Execution API
/**
* Google apps script ID
*/
const SCRIPTID = 'M6_REvtEnxTdstkFPTpMBrkRmolM6jgKW';
/**
* Google apps script function name
*/
const EXECUTE_FUNCTION = 'getSheetJSON';
fetch(`https://script.googleapis.com/v1/scripts/${CONSTANTS.SCRIPTID}:run`, {
method: 'post',
headers: {
Authorization: 'Bearer ' + oauth.token,
},
body: JSON.stringify({
function: CONSTANTS.EXECUTE_FUNCTION,
parameters: [sheet.id],
devMode: true,
}),
})
.then(response => response.json())
.then(json => dispatch(receiveSheet(sheet, json)));
benefit
◎ No database management
◎ Each user can have their own orgree data in
private spreadsheet (grant oauth)
Demo
fetch specific spreadsheet data via
Google Apps Script Execution API
3.
Google Apps Script
for Mobile
developers
Let’s start with the third set of
slides
employee App
Architecture
Data in spreadsheet
Content Service (JSON)
employee App - outline
◎ Data in Spreadsheet setup
◎ Content Service (JSON) - App Script
◎ iOS - calling restful API (react native)
employee spreadsheet Data
Level ID Parent Type * Title Email
1 A00 root D 資訊研發處 A00@aa.bb.cc
2 A10 A00 D 資訊研發部 A10@aa.bb.cc
3 SunnyHu A10 U 胡適 hushi@aa.bb.cc
3 SimonSu A10 U 蘇武 suwu@aa.bb.cc
2 EthanChang A00 U 張三 zhangshang@aa.bb.cc
1 B00 root D 技術支援處 B00@aa.bb.cc
2 BensonChen B00 U 陳班森 bensonchen@gov.tw
[iOS Taipei - employee Data - Google Sheets](https://goo.
gl/A1Hdqd)
Content Service (JSON) App Script
function doGet() {
var ss = SpreadsheetApp.openById('1QgsaX4Vn_lIwLFRC_iHs6gmJYIP4y-35nVqQOpz4B0s');
var sheet = ss.getSheets()[0];
// Get the range of cells that store employee data.
var employeeDataRange = ss.getRangeByName("employeeData");
// For every row of employee data, generate an employee object.
var employeeObjects = getRowsData(sheet, employeeDataRange);
return ContentService.createTextOutput(JSON.stringify(employeeObjects)).setMimeType(ContentService.
MimeType.JSON);
}
...
Read specific spreadsheet content
and return JSON string
[iOS Taipei - employee Data](https://goo.gl/NpdIrQ)
Content Service (JSON) App Script - continue
Publish/Deploy as web app
Content Service (JSON) App Script - continue
$ curl -L https://script.google.com/macros/s/AKfycbz4Z2dm-MUidB98H5XbekL0LZnvPVRM3ekpG-NSrScc9tvI87A/exec
[{"level":1,"id":"A00","parent":"root","type":"D","title":"資訊研發處","email":"A00@aa.bb.cc"},{"level":
2,"id":"A10","parent":"A00","type":"D","title":"資訊研發部","email":"A10@aa.bb.cc"},{"level":3,"id":"
SunnyHu","parent":"A10","type":"U","title":"胡適","email":"hushi@aa.bb.cc"},{"level":3,"id":"SimonSu","
parent":"A10","type":"U","title":"蘇武","email":"suwu@aa.bb.cc"},{"level":2,"id":"EthanChang","parent":"
A00","type":"U","title":"張三","email":"zhangshang@aa.bb.cc"},{"level":1,"id":"B00","parent":"root","
type":"D","title":"技術支援處","email":"B00@aa.bb.cc"},{"level":2,"id":"BensonChen","parent":"B00","
type":"U","title":"陳班森","email":"bensonchen@aa.bb.cc"}]
iOS employee App - react native
var React = require('react-native');
var {AppRegistry, StyleSheet, Text, View, ListView, TouchableOpacity, AlertIndicatorIOS,
ActivityIndicatorIOS, AlertIOS} = React;
var SPREADSHEET_WEB_API_URL = 'https://script.google.com/macros/s/AKfycbz4Z2dm-MUidB98H5XbekL0LZnvPVRM3ekpG-
NSrScc9tvI87A/exec';
class AwesomeProject extends React.Component {
...
fetchData () {
fetch(SPREADSHEET_WEB_API_URL).then((response) => response.json()).then((responseData)=>{
let dataBlob = [];
responseData.forEach(item=>{dataBlob.push(`${item.title} - ${item.email}`);});
this.setState({dataSource: this.state.dataSource.cloneWithRows(dataBlob), loaded: true});
}).done();
}
render () {
...
}
}
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
Demo
calling restful service and get JSON
back
Let’s review some concepts
Content Service
Google Apps Script support
ContentService that allows for
data to be served from
Spreadsheet with your logic
Simple backend
store your data in Google
Spreadsheet without build another
database for small project
4.
Tips & Study
information
Let’s start with the fourth set of
slides
“
Google Apps Script function not
found: doGet.
You need to save a new version and publish
the new version to make sure your app gets
updated properly
File -> Manage versions...
[javascript - Google Apps Script function not found: doGet - Stack Overflow](http://goo.gl/CXxAOT)
“
[Script It! with Android - YouTube](https://www.youtube.com/watch?v=RSgMEtRl0sw&list=PL68F511F6E3C122EB)
Study information
◎ [Google apps script - simon su](http://www.slideshare.
net/peihsinsu/google-apps-script-24469585)
◎ [entaq/GoogleAppsScript](https://github.com/entaq/GoogleAppsScript)
○ [Script It! with Android - YouTube](https://www.youtube.com/watch?
v=RSgMEtRl0sw&list=PL68F511F6E3C122EB)
○ [Apps Script Crash Course: ContentService - YouTube](https://www.
youtube.com/watch?v=JRGzVdliQOQ&list=PL68F511F6E3C122EB)
◎ [Apps Script | Google Developers](https://developers.google.com/apps-
script/)
◎ [Google Apps Script 入門與應用 - 資訊學科中心](http://icerc.tnssh.tn.edu.
tw/download/rs/1030429_3.pdf)
Study information - examples
◎ [Generate EPUB file with Google Apps Scripts | blog.softapalvelin.com](http:
//blog.softapalvelin.com/2013/02/generate-epub-file-with-google-app.html)
○ [RSSToEPUB](https://goo.gl/YCDDBo)
◎ [google/google-apps-script-samples](https://github.com/google/google-
apps-script-samples)
◎ [Tutorials | Apps Script | Google Developers](https://developers.google.
com/apps-script/articles)
◎ [Parsing HTML - Google Apps Script Examples](https://sites.google.
com/site/scriptsexamples/learn-by-example/parsing-html)
Thanks!
Any questions?
You can find me at:
http://kaichu.io
cage.chung@gmail.com

Más contenido relacionado

La actualidad más candente

Praneet’s Pre On ChatGpt edited.pptx
Praneet’s Pre On ChatGpt edited.pptxPraneet’s Pre On ChatGpt edited.pptx
Praneet’s Pre On ChatGpt edited.pptx
Salunke2
 
The Corporate Innovation Playbook
The Corporate Innovation PlaybookThe Corporate Innovation Playbook
The Corporate Innovation Playbook
Wikibrands - Transformation & Futureproofing
 

La actualidad más candente (20)

Getting Started with ChatGPT.pdf
Getting Started with ChatGPT.pdfGetting Started with ChatGPT.pdf
Getting Started with ChatGPT.pdf
 
Optimize Your Funnel By Getting Inside Your Buyer's Head
Optimize Your Funnel By Getting Inside Your Buyer's HeadOptimize Your Funnel By Getting Inside Your Buyer's Head
Optimize Your Funnel By Getting Inside Your Buyer's Head
 
SharePoint Beginner Training for End Users
SharePoint Beginner Training for End UsersSharePoint Beginner Training for End Users
SharePoint Beginner Training for End Users
 
Microsoft AI Platform Overview
Microsoft AI Platform OverviewMicrosoft AI Platform Overview
Microsoft AI Platform Overview
 
Enhancing Microsoft Teams To Build A Better Digital Workplace
Enhancing Microsoft Teams To Build A Better Digital WorkplaceEnhancing Microsoft Teams To Build A Better Digital Workplace
Enhancing Microsoft Teams To Build A Better Digital Workplace
 
Digital marketing workshop
Digital marketing workshopDigital marketing workshop
Digital marketing workshop
 
The History of SEO
The History of SEOThe History of SEO
The History of SEO
 
Microsoft Marketing Strategies
Microsoft Marketing StrategiesMicrosoft Marketing Strategies
Microsoft Marketing Strategies
 
20 Microsoft 365 Productivity Tips
20 Microsoft 365 Productivity Tips20 Microsoft 365 Productivity Tips
20 Microsoft 365 Productivity Tips
 
Praneet’s Pre On ChatGpt edited.pptx
Praneet’s Pre On ChatGpt edited.pptxPraneet’s Pre On ChatGpt edited.pptx
Praneet’s Pre On ChatGpt edited.pptx
 
On-Page & Off-Page SEO Check List
On-Page & Off-Page SEO Check ListOn-Page & Off-Page SEO Check List
On-Page & Off-Page SEO Check List
 
Optimize Your Sales & Marketing Funnel
Optimize Your Sales & Marketing FunnelOptimize Your Sales & Marketing Funnel
Optimize Your Sales & Marketing Funnel
 
Small Business in the Age of AI
Small Business in the Age of AI Small Business in the Age of AI
Small Business in the Age of AI
 
AI FOR BUSINESS LEADERS
AI FOR BUSINESS LEADERSAI FOR BUSINESS LEADERS
AI FOR BUSINESS LEADERS
 
Microsoft Viva Essential in 45 minutes - Collabdays Bletchley 2022
Microsoft Viva Essential in 45 minutes - Collabdays Bletchley 2022Microsoft Viva Essential in 45 minutes - Collabdays Bletchley 2022
Microsoft Viva Essential in 45 minutes - Collabdays Bletchley 2022
 
Social Media Content Strategy
Social Media Content StrategySocial Media Content Strategy
Social Media Content Strategy
 
A complete digital marketing sop divay jain ( profshine tech )
A complete digital marketing sop  divay jain ( profshine tech )A complete digital marketing sop  divay jain ( profshine tech )
A complete digital marketing sop divay jain ( profshine tech )
 
10 influencer marketing facts
10 influencer marketing facts10 influencer marketing facts
10 influencer marketing facts
 
The Corporate Innovation Playbook
The Corporate Innovation PlaybookThe Corporate Innovation Playbook
The Corporate Innovation Playbook
 
ChatGPT, Generative AI and Microsoft Copilot: Step Into the Future - Geoff Ab...
ChatGPT, Generative AI and Microsoft Copilot: Step Into the Future - Geoff Ab...ChatGPT, Generative AI and Microsoft Copilot: Step Into the Future - Geoff Ab...
ChatGPT, Generative AI and Microsoft Copilot: Step Into the Future - Geoff Ab...
 

Destacado

Destacado (11)

Continuous Integration & Continuous Delivery with GCP
Continuous Integration & Continuous Delivery with GCPContinuous Integration & Continuous Delivery with GCP
Continuous Integration & Continuous Delivery with GCP
 
Nas 也可以揀土豆
Nas 也可以揀土豆Nas 也可以揀土豆
Nas 也可以揀土豆
 
Waldo-gcp
Waldo-gcpWaldo-gcp
Waldo-gcp
 
痞客趴趴走 Waldo
痞客趴趴走   Waldo痞客趴趴走   Waldo
痞客趴趴走 Waldo
 
Gae managed vm introduction
Gae managed vm introductionGae managed vm introduction
Gae managed vm introduction
 
Google app engine (gae) 演進史
Google app engine (gae) 演進史Google app engine (gae) 演進史
Google app engine (gae) 演進史
 
Django oscar introduction
Django oscar introductionDjango oscar introduction
Django oscar introduction
 
Introduction to chrome extension development
Introduction to chrome extension developmentIntroduction to chrome extension development
Introduction to chrome extension development
 
Screenshot as a service
Screenshot as a serviceScreenshot as a service
Screenshot as a service
 
Google apps script introduction
Google apps script introductionGoogle apps script introduction
Google apps script introduction
 
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
 

Similar a Google apps script introduction

Google: Drive, Documents and Apps Script - How to work efficiently and happily
Google:  Drive, Documents  and Apps Script - How to work efficiently and happilyGoogle:  Drive, Documents  and Apps Script - How to work efficiently and happily
Google: Drive, Documents and Apps Script - How to work efficiently and happily
Alessandra Santi
 
Advanced query parsing techniques
Advanced query parsing techniquesAdvanced query parsing techniques
Advanced query parsing techniques
lucenerevolution
 

Similar a Google apps script introduction (20)

Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)
 
Google Cloud lightning talk @MHacks
Google Cloud lightning talk @MHacksGoogle Cloud lightning talk @MHacks
Google Cloud lightning talk @MHacks
 
Data Science on Google Cloud Platform
Data Science on Google Cloud PlatformData Science on Google Cloud Platform
Data Science on Google Cloud Platform
 
Cloud computing overview & running your code on Google Cloud
Cloud computing overview & running your code on Google CloudCloud computing overview & running your code on Google Cloud
Cloud computing overview & running your code on Google Cloud
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
 
Google: Drive, Documents and Apps Script - How to work efficiently and happily
Google:  Drive, Documents  and Apps Script - How to work efficiently and happilyGoogle:  Drive, Documents  and Apps Script - How to work efficiently and happily
Google: Drive, Documents and Apps Script - How to work efficiently and happily
 
Using Google (Cloud) APIs
Using Google (Cloud) APIsUsing Google (Cloud) APIs
Using Google (Cloud) APIs
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricks
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricks
 
Art & music vs Google App Engine
Art & music vs Google App EngineArt & music vs Google App Engine
Art & music vs Google App Engine
 
The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's How
 
Google Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScriptGoogle Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScript
 
Google Cloud Platform
Google Cloud Platform Google Cloud Platform
Google Cloud Platform
 
How to build unified Batch & Streaming Pipelines with Apache Beam and Dataflow
How to build unified Batch & Streaming Pipelines with Apache Beam and DataflowHow to build unified Batch & Streaming Pipelines with Apache Beam and Dataflow
How to build unified Batch & Streaming Pipelines with Apache Beam and Dataflow
 
Google Big Query UDFs
Google Big Query UDFsGoogle Big Query UDFs
Google Big Query UDFs
 
Cloud computing overview & running your code on Google Cloud (Jun 2019)
Cloud computing overview & running your code on Google Cloud (Jun 2019)Cloud computing overview & running your code on Google Cloud (Jun 2019)
Cloud computing overview & running your code on Google Cloud (Jun 2019)
 
Powerful Google Cloud tools for your hack (2020)
Powerful Google Cloud tools for your hack (2020)Powerful Google Cloud tools for your hack (2020)
Powerful Google Cloud tools for your hack (2020)
 
Advanced Relevancy Ranking
Advanced Relevancy RankingAdvanced Relevancy Ranking
Advanced Relevancy Ranking
 
Advanced query parsing techniques
Advanced query parsing techniquesAdvanced query parsing techniques
Advanced query parsing techniques
 

Más de KAI CHU CHUNG

Más de KAI CHU CHUNG (15)

Devfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfDevfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdf
 
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdfDevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
 
DevFest 2022 - Cloud Workstation Introduction TaiChung
DevFest 2022 - Cloud Workstation Introduction TaiChungDevFest 2022 - Cloud Workstation Introduction TaiChung
DevFest 2022 - Cloud Workstation Introduction TaiChung
 
Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)
 
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
 
Velero search & practice 20210609
Velero search & practice 20210609Velero search & practice 20210609
Velero search & practice 20210609
 
Gdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpackGdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpack
 
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API AuthorizationGDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
 
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
 
Google App Engine: Basic
Google App Engine: BasicGoogle App Engine: Basic
Google App Engine: Basic
 
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
 
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
Global GDG Leaders Summit, Google I/O 2018 經驗分享
Global GDG Leaders Summit, Google I/O 2018 經驗分享Global GDG Leaders Summit, Google I/O 2018 經驗分享
Global GDG Leaders Summit, Google I/O 2018 經驗分享
 

Último

➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
nirzagarg
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Chandigarh Call girls 9053900678 Call girls in Chandigarh
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
imonikaupta
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Último (20)

Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 

Google apps script introduction

  • 2. https://www.facebook.com/groups/GCPUG.TW/ https://plus.google.com/u/0/communities/116100913832589966421 Google Cloud Platform User Group Taiwan 我們是Google Cloud Platform Taiwan User Group。在Google雲端服務在台灣地區展露頭角之後, 有許多新的服務、新的知識、新的創意,歡迎大家一起分享,一起了解 Google雲端服務... GCPUG透過網際網路串聯喜好 Google Cloud的使用者,分享與交流使用 GCP的點滴鑑驗。如果您 是Google Cloud Platform的初學者,您應該來聽聽前輩們的使用經驗;如果您是 Google Cloud Platform的Expert,您應該來分享一下寶貴的經驗,並與更多高手互相交流;如果您還沒開始用 Google Cloud Platform,那麼您應該馬上來聽聽我們是怎麼使用 Google Cloud的!
  • 3. Hello! I am Cage Chung I am here because I like to share my experiences. You can find me at: http://kaichu.io
  • 4. Outline ◎ What’s Google Apps Script? ◎ Case study - Orgtree chrome extension ◎ Google Apps Script for Mobile developers ◎ Tips & Study information
  • 5. 1. What’s Google App Scripts Let’s start with the first set of slides
  • 6. “ Google Apps Script is a scripting language based on JavaScript that lets you do new and cool things with Google Apps
  • 7. Where Google apps, 1 platform in the cloud
  • 8. Add-ons for Google Apps Google Sheets, Docs, and Forms Add-ons run inside Google Sheets, Docs, and Forms
  • 9. Add-ons for Google Apps - continue
  • 10. Google Service ◎ Calendar ◎ Contacts ◎ Documents ◎ Domain Deprecated ◎ Drive ◎ Forms ◎ Gmail ◎ Groups ◎ Language ◎ Maps ◎ Sites ◎ Spreadsheet
  • 11. Advances Google Service ◎ Admin SDK ◎ AdSense ◎ Analytics ◎ App Activity ◎ BigQuery ◎ Calendar ◎ Classroom ◎ Drive ◎ DoubleClick Campaigns ◎ Fusion Table ◎ Gmail ◎ Google+ ◎ Google+ Domains ◎ Mirror ◎ Prediction ◎ Shopping Content ◎ Tasks ◎ URL Shortener ◎ YouTube
  • 12. Type of Scripts - Standalone Standalone is any script that is not bound to a Google Sheets, Docs, or Forms file or Google Sites. // Log the name of every file in the user's Drive that modified after February 28, // 2013 whose name contains "untitled". function doAction(){ var files = DriveApp.searchFiles( 'modifiedDate > "2015-01-01" and title contains "untitled"'); while (files.hasNext()) { var file = files.next(); Logger.log(file.getName()); } } [iOS Taipei - Apps Script - Type of Scripts - Standalone](https://goo.gl/oj8WVO)
  • 13. Bound to Google Apps A script is bound to a Google Sheets, Docs, or Forms file. Type of Scripts - Bound to Google Apps function doAction(range) { // Get the active spreadsheet and the active sheet var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getActiveSheet(); // Get the range of cells that store employee data. var libraryDataRange = sheet.getRange(range); var libraryObjects = getRowsData(sheet, libraryDataRange, 1); libraryObjects.forEach(function (row, index) { var latlng = getLatitudeLongitude(row.address) if (latlng) { sheet.getRange(index + 2, 5, 1, 1).setValue(latlng.lat); sheet.getRange(index + 2, 6, 1, 1).setValue(latlng.lng); } }); }
  • 14. Type of Scripts - Bound to Google Apps. continue [coffeemap-testing-form - Google Sheets](https://goo.gl/ZAIOtT) [coffeemap](https://goo.gl/Wb91tW) quick setup form [Coffee Stores Map](https://goo.gl/Wg6mWu) Trigger and Events Triggers let Apps Script run a function automatically when a certain event, like opening a document, occurs.
  • 15. Web Apps and Site Gadgets If you build a user interface for a script, you can publish the script as a web app. ◎ It contains a doGet(e) and doPost(e) function. ◎ The function returns an HTML service HtmlOutput object or a Content service TextOutput object. Type of Scripts - Web Apps and Site Gadgets
  • 16. Type of Scripts - Web Apps and Site Gadgets. continue function doGet() { var ss = SpreadsheetApp.openById('1QgsaX4Vn_lIwLFRC_iHs6gmJYIP4y-35nVqQOpz4B0s'); var sheet = ss.getSheets()[0]; // Get the range of cells that store employee data. var employeeDataRange = ss.getRangeByName("employeeData"); // For every row of employee data, generate an employee object. var employeeObjects = getRowsData(sheet, employeeDataRange); return ContentService.createTextOutput(JSON.stringify(employeeObjects)).setMimeType(ContentService. MimeType.JSON); } ... [iOS Taipei - employee Data](https://goo.gl/NpdIrQ) $ curl -L https://script.google.com/macros/s/AKfycbz4Z2dm-MUidB98H5XbekL0LZnvPVRM3ekpG-NSrScc9tvI87A/exec [{"level":1,"id":"A00","parent":"root","type":"D","title":"資訊研發處","email":"A00@aa.bb.cc"},{"level":2," id":"A10","parent":"A00","type":"D","title":"資訊研發部","email":"A10@aa.bb.cc"},{"level":3,"id":"SunnyHu"," parent":"A10","type":"U","title":"胡適 ...
  • 17. 2. Case Study - Orgtree Chrome extension Let’s start with the second set of slides
  • 18. Big concept Insert your own organization contacts to Gmail and Drive with ease
  • 19. Place your screenshot here Orgtree chrome extension - Gmail
  • 20. Place your screenshot here Orgtree chrome extension - Drive
  • 21. Place your screenshot here Orgtree chrome extension - Pick Spreadsheet
  • 22. Orgtree architecture Google Apps Script Execution API Orgtree Chrome extension Spreadsheet
  • 23. orgtree-example-data Level ID Parent Type * Title Email 1 A00 root D 資訊研發處 A00@aa.bb.cc 2 A10 A00 D 資訊研發部 A10@aa.bb.cc 3 SunnyHu A10 U 胡適 hushi@aa.bb.cc 3 SimonSu A10 U 蘇武 suwu@aa.bb.cc 2 EthanChang A00 U 張三 zhangshang@aa.bb.cc 1 B00 root D 技術支援處 B00@aa.bb.cc 2 BensonChen B00 U 陳班森 bensonchen@aa.bb.cc [orgtree - sheet 2 json](https://goo.gl/WmaHmG)
  • 24. Apps Script function getSheetJSON(sheetId) { var ss = SpreadsheetApp.openById(sheetId); var sheets = ss.getSheets(); var json = sheets.map(function(sheet) { return convertSheet2JsonText(sheet); }); return JSON.stringify(json); } function convertSheet2JsonText(sheet) { // read spreadsheet value to array ... return jsonArray; }
  • 25. Apps Script - continue ◎ Files/Project properties/scopes - https://www. googleapis.com/auth/spreadsheets ◎ Resources/Developers Console Project - Link Google Console Project ○ Google Apps Script Execution API - Register OAuth 2.0 client IDs required.
  • 26. Google Apps Script Execution API /** * Google apps script ID */ const SCRIPTID = 'M6_REvtEnxTdstkFPTpMBrkRmolM6jgKW'; /** * Google apps script function name */ const EXECUTE_FUNCTION = 'getSheetJSON'; fetch(`https://script.googleapis.com/v1/scripts/${CONSTANTS.SCRIPTID}:run`, { method: 'post', headers: { Authorization: 'Bearer ' + oauth.token, }, body: JSON.stringify({ function: CONSTANTS.EXECUTE_FUNCTION, parameters: [sheet.id], devMode: true, }), }) .then(response => response.json()) .then(json => dispatch(receiveSheet(sheet, json)));
  • 27. benefit ◎ No database management ◎ Each user can have their own orgree data in private spreadsheet (grant oauth)
  • 28. Demo fetch specific spreadsheet data via Google Apps Script Execution API
  • 29. 3. Google Apps Script for Mobile developers Let’s start with the third set of slides
  • 30. employee App Architecture Data in spreadsheet Content Service (JSON)
  • 31. employee App - outline ◎ Data in Spreadsheet setup ◎ Content Service (JSON) - App Script ◎ iOS - calling restful API (react native)
  • 32. employee spreadsheet Data Level ID Parent Type * Title Email 1 A00 root D 資訊研發處 A00@aa.bb.cc 2 A10 A00 D 資訊研發部 A10@aa.bb.cc 3 SunnyHu A10 U 胡適 hushi@aa.bb.cc 3 SimonSu A10 U 蘇武 suwu@aa.bb.cc 2 EthanChang A00 U 張三 zhangshang@aa.bb.cc 1 B00 root D 技術支援處 B00@aa.bb.cc 2 BensonChen B00 U 陳班森 bensonchen@gov.tw [iOS Taipei - employee Data - Google Sheets](https://goo. gl/A1Hdqd)
  • 33. Content Service (JSON) App Script function doGet() { var ss = SpreadsheetApp.openById('1QgsaX4Vn_lIwLFRC_iHs6gmJYIP4y-35nVqQOpz4B0s'); var sheet = ss.getSheets()[0]; // Get the range of cells that store employee data. var employeeDataRange = ss.getRangeByName("employeeData"); // For every row of employee data, generate an employee object. var employeeObjects = getRowsData(sheet, employeeDataRange); return ContentService.createTextOutput(JSON.stringify(employeeObjects)).setMimeType(ContentService. MimeType.JSON); } ... Read specific spreadsheet content and return JSON string [iOS Taipei - employee Data](https://goo.gl/NpdIrQ)
  • 34. Content Service (JSON) App Script - continue Publish/Deploy as web app
  • 35. Content Service (JSON) App Script - continue $ curl -L https://script.google.com/macros/s/AKfycbz4Z2dm-MUidB98H5XbekL0LZnvPVRM3ekpG-NSrScc9tvI87A/exec [{"level":1,"id":"A00","parent":"root","type":"D","title":"資訊研發處","email":"A00@aa.bb.cc"},{"level": 2,"id":"A10","parent":"A00","type":"D","title":"資訊研發部","email":"A10@aa.bb.cc"},{"level":3,"id":" SunnyHu","parent":"A10","type":"U","title":"胡適","email":"hushi@aa.bb.cc"},{"level":3,"id":"SimonSu"," parent":"A10","type":"U","title":"蘇武","email":"suwu@aa.bb.cc"},{"level":2,"id":"EthanChang","parent":" A00","type":"U","title":"張三","email":"zhangshang@aa.bb.cc"},{"level":1,"id":"B00","parent":"root"," type":"D","title":"技術支援處","email":"B00@aa.bb.cc"},{"level":2,"id":"BensonChen","parent":"B00"," type":"U","title":"陳班森","email":"bensonchen@aa.bb.cc"}]
  • 36. iOS employee App - react native var React = require('react-native'); var {AppRegistry, StyleSheet, Text, View, ListView, TouchableOpacity, AlertIndicatorIOS, ActivityIndicatorIOS, AlertIOS} = React; var SPREADSHEET_WEB_API_URL = 'https://script.google.com/macros/s/AKfycbz4Z2dm-MUidB98H5XbekL0LZnvPVRM3ekpG- NSrScc9tvI87A/exec'; class AwesomeProject extends React.Component { ... fetchData () { fetch(SPREADSHEET_WEB_API_URL).then((response) => response.json()).then((responseData)=>{ let dataBlob = []; responseData.forEach(item=>{dataBlob.push(`${item.title} - ${item.email}`);}); this.setState({dataSource: this.state.dataSource.cloneWithRows(dataBlob), loaded: true}); }).done(); } render () { ... } } AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
  • 37. Demo calling restful service and get JSON back
  • 38. Let’s review some concepts Content Service Google Apps Script support ContentService that allows for data to be served from Spreadsheet with your logic Simple backend store your data in Google Spreadsheet without build another database for small project
  • 39. 4. Tips & Study information Let’s start with the fourth set of slides
  • 40. “ Google Apps Script function not found: doGet. You need to save a new version and publish the new version to make sure your app gets updated properly File -> Manage versions... [javascript - Google Apps Script function not found: doGet - Stack Overflow](http://goo.gl/CXxAOT)
  • 41. “ [Script It! with Android - YouTube](https://www.youtube.com/watch?v=RSgMEtRl0sw&list=PL68F511F6E3C122EB)
  • 42. Study information ◎ [Google apps script - simon su](http://www.slideshare. net/peihsinsu/google-apps-script-24469585) ◎ [entaq/GoogleAppsScript](https://github.com/entaq/GoogleAppsScript) ○ [Script It! with Android - YouTube](https://www.youtube.com/watch? v=RSgMEtRl0sw&list=PL68F511F6E3C122EB) ○ [Apps Script Crash Course: ContentService - YouTube](https://www. youtube.com/watch?v=JRGzVdliQOQ&list=PL68F511F6E3C122EB) ◎ [Apps Script | Google Developers](https://developers.google.com/apps- script/) ◎ [Google Apps Script 入門與應用 - 資訊學科中心](http://icerc.tnssh.tn.edu. tw/download/rs/1030429_3.pdf)
  • 43. Study information - examples ◎ [Generate EPUB file with Google Apps Scripts | blog.softapalvelin.com](http: //blog.softapalvelin.com/2013/02/generate-epub-file-with-google-app.html) ○ [RSSToEPUB](https://goo.gl/YCDDBo) ◎ [google/google-apps-script-samples](https://github.com/google/google- apps-script-samples) ◎ [Tutorials | Apps Script | Google Developers](https://developers.google. com/apps-script/articles) ◎ [Parsing HTML - Google Apps Script Examples](https://sites.google. com/site/scriptsexamples/learn-by-example/parsing-html)
  • 44. Thanks! Any questions? You can find me at: http://kaichu.io cage.chung@gmail.com