【MACRO】Google Apps Script 質問スレ【DRIVE】

2014/06/29(日) 11:07:03.38ID:5HmND7Qc
Google Apps Script でのプログラミング等に関する質問スレです
Excel や Access の VBA に不満のあるあなた
web アプリだけでなくクライアントアプリからも利用したいあなた
ローカルなデータベースやファイルだとバックアップに不安のあるあなた

ム板に無かったので立ててみます

Google Apps Script
ttps://developers.google.com/apps-script/
Google Drive API
ttps://developers.google.com/drive/
Getting Started with the Google Data Python Library
ttps://developers.google.com/gdata/articles/python_client_lib

■関連スレ
Google Maps API 質問箱
http://peace.2ch.net/test/read.cgi/tech/1131627583/
Microsoft SkyDrive API
http://peace.2ch.net/test/read.cgi/tech/1385604796/
【GoogleAppsScript】猿92【研究せよ!!!】
http://nozomi.2ch.net/test/read.cgi/php/1398600864/
GoogleAPIってどうよ?
http://nozomi.2ch.net/test/read.cgi/php/1018614427/
Google App Engine for Python 6アプ目
http://nozomi.2ch.net/test/read.cgi/php/1358570953/
Google App Engine for java
http://peace.2ch.net/test/read.cgi/tech/1317639323/
GoogleWebToolkit[GWT]について語ろう
http://nozomi.2ch.net/test/read.cgi/php/1147975874/
2014/06/29(日) 11:07:58.27ID:5HmND7Qc
■お役立ちリンク
gdata-python-client
ttps://code.google.com/p/gdata-python-client/
Google Documents List API v1 Developer's Guide: Protocol (古い)
ttps://developers.google.com/google-apps/documents-list/v1/developers_guide_python
ScriptDB
ttps://developers.google.com/apps-script/reference/script-db
ScrptDb
ttp://libro.tuyano.com/index3?id=921001

Using OAuth 2.0 to Access Google APIs
ttps://developers.google.com/accounts/docs/OAuth2
Using OAuth 2.0 for Login (OpenID Connect)
ttps://developers.google.com/accounts/docs/OAuth2Login

ドライブの認証と承認について
ttps://developers.google.com/drive/training/drive-apps/auth/about
OAuth 2.0 認証情報を取得して使用する
ttps://developers.google.com/drive/training/drive-apps/auth/credentials
2014/06/29(日) 11:08:27.65ID:5HmND7Qc
一見すごい乱暴な仕様なんだけど実用上は問題ないということなんだろうな
https://www.youtube.com/watch?v=lEVMu9KE6jk
https://www.youtube.com/watch?v=ezbH4IJynhU
http://www.scoop.it/t/gas
2014/06/29(日) 11:09:52.86ID:wFk5OUc5
               ノ      ゚.ノヽ  , /}      ...
            ,,イ`"     、-'   `;_' '    ..::::::::::::::...
   ,-、  _.._   (        (,(~ヽ'~     ..:::::::::::::::::::::::
 )'~  レー'  〉   ヽ       i`'}       .:::::::::::::::::::::::
 ~つ     '-ー、  i       | i'     ...:::::::::::::::::::::::
 /       <  /     。/   !  ......:::::::::::::::::::::::::    これは>>1乙じゃなくて
/         ~^´     /},-'' ,●::::::::::::::::::::::::::::::::::::
i、        ,i' _,,...,-‐-、/    i  ::::::::  .:::::::::::::
..ゝ        <,,-==、   ,,-,/      .:::::::::::            放射能がうんたら
 )       {~''~>`v-''`ー゙`'~       ..:::::::::                          ........::.
 {        レ_ノ            ..::::::::.                         ......:::::::::
ノ         ''           ..:::::::                        ...::.:...:::::::::
                     .:::::::::                     ...:......:::::::::::: .
                    .:::::::::::.        .....      ..  ..::::::::::::::::::::::::   :::.
                    ::::::::::::::::.::::::....:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::.. ::  ::..
                    .:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::    ::.
                    ::::::::::::::::: :::::::::::::::::::::::::::::: :::::
                          .::    ::.  :::
2014/06/29(日) 11:18:48.90ID:wFk5OUc5
Google Drive APIをRuby on Railsから叩く方法
http://www.eisbahn.jp/yoichiro/2012/10/google-drive-api-ruby-on-rails.html

+関連スレ
Windows Azure プログラミング 総合スレ2
http://peace.2ch.net/test/read.cgi/tech/1359450980/
2014/06/29(日) 11:21:28.69ID:vvQOaiPq
クラウドAPIスレにすれば良かったのに
2014/06/29(日) 12:06:09.80ID:tO69Jiz2
あとで見るリスト
Google Apps Unscripted, March 14, 2014
https://www.youtube.com/watch?v=E1CzPtUKWkw
Google Drive SDK: Building Drive apps entirely on the cloud with Google Apps Script
https://www.youtube.com/watch?v=R71oo-5NmPE
Google I/O 2013 - Integrate Google Drive with Google Apps Script
https://www.youtube.com/watch?v=0HVJMIeb3aE
Google I/O 2012 - Storing Data in Google Apps Script
https://www.youtube.com/watch?v=8lJewIWVI5s
State of the Script 2013
https://www.youtube.com/watch?v=b0GkGlG6kQY
Apps Script Crash Course: ContentService
https://www.youtube.com/watch?v=JRGzVdliQOQ
Google I/O 2013 - Use Apps Script to Create Dynamic Google Forms
https://www.youtube.com/watch?v=38H7WpsTD0M
2014/06/29(日) 12:12:11.08ID:tO69Jiz2
Google I/O 2012 - Use What You Know: HTML and JavaScript in Apps Script
https://www.youtube.com/watch?v=tcl24asytos
Google Apps Unscripted - March 2013
https://www.youtube.com/watch?v=SKZmfgNesKs
Google I/O 2012 - OAuth 2.0 for Identity and Data Access
https://www.youtube.com/watch?v=YLHyeSuBspI
2014/06/29(日) 12:40:23.92ID:tO69Jiz2
Google Drive SDK: Writing your first Drive app in Python
https://www.youtube.com/watch?v=zJVCKvXtHtE
2014/06/29(日) 12:42:11.61ID:tO69Jiz2
Google Drive SDKのクイックスタートをやってみる for Python
http://everyday-01.blogspot.jp/2013/01/google-drive-sdkpython.html
pythonでGoogle Driveにファイル転送
http://good-morning-call.com/2013/01/28/python%E3%81%A7google-drive%E3%81%AB%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E8%BB%A2%E9%80%81/
PythonからGoogle Driveにフォルダを作成する方法
http://d.hatena.ne.jp/kaorumori/20120518/1338218268
GoogleDriveAPIでHTMLファイルを作成し、GoogleドライブでWebサイト公開してアルクマを追いかける
http://d.hatena.ne.jp/thinkAmi/20121218/1355779644
Google DriveAPIでのHTMLファイル作成、GAEでのOAuth認証とコールバック実装
http://d.hatena.ne.jp/thinkAmi/20121229/1356735544
Google Drive APIによるファイル管理 (1-5/5) javascript
http://libro.tuyano.com/index3?id=1166003
Google API Client for Python Documentation
http://api-python-client-doc.appspot.com/
GoogleDriveAPI for Python
https://developers.google.com/drive/quickstart-python
Download Client Libraries
https://developers.google.com/drive/downloads
Google Drive API
https://developers.google.com/drive/
BigQuery
https://developers.google.com/bigquery/what-is-bigquery
Google Cloud Datastore
https://developers.google.com/datastore/
Google Cloud Storage Overview
https://developers.google.com/storage/docs/json_api/
Google Maps Coordinate API
https://developers.google.com/coordinate/
Google Fonts Developer API
https://developers.google.com/fonts/docs/developer_api
Using OAuth 2.0 to Access Google APIs
https://developers.google.com/accounts/docs/OAuth2
2014/06/29(日) 12:45:33.92ID:tO69Jiz2
Google Cloud Datastore: A Fully Managed NoSQL Data Storage Service
https://www.youtube.com/watch?v=fQazhzcC-rg
2014/06/29(日) 12:52:51.76ID:tO69Jiz2
Google APIs Client for Python (includes for Google App Engine)
https://developers.google.com/api-client-library/python/

だぶってたらすまそ
2014/06/29(日) 14:13:30.73ID:tO69Jiz2
Google Caja
https://developers.google.com/caja/

Overview of Google Apps Script
https://developers.google.com/apps-script/overview
Tutorial: Leveraging Google App Engine services from scripts
https://developers.google.com/apps-script/articles/appengine?hl=ja
Properties Service
https://developers.google.com/apps-script/guides/properties

Google Apps Script : To store data on google Cloud Sorage
http://blog.knoldus.com/2013/01/19/google-apps-script-to-store-data-on-google-cloud-sorage/
Google Apps Script: How to store data on google cloud storage?
http://stackoverflow.com/questions/12744957/google-apps-script-how-to-store-data-on-google-cloud-storage
Google Apps ScriptのPrediction Serviceを使ってみた
http://qiita.com/ttyokoyama/items/1aac9078d34b0daf1d44
BigQuery API の利用 (1-5)
http://libro.tuyano.com/index3?id=901002
2014/06/29(日) 14:30:36.95ID:tO69Jiz2
この人の声は聴きとり易いな
Your First Script - Apps Script Tutorials
https://www.youtube.com/watch?v=Pgfbl_o9WvM
2014/06/29(日) 16:08:56.60ID:tO69Jiz2
https://developers.google.com/apps-script/overview
ここを見ながら最初のスクリプトを書いてみた

Google Drive 上であらかじめ spreadsheet を一つ作って出来たファイルの ID を調べておく
Google Drive の [Create] から [Script] を選択し [Blank Project]
([Script] が無いときは [Create] の一番下の [Connect more apps] を選んで
[検索] apps script で出て来る [Google Apps Script] をインストール)
Script Editor の画面になったら以下のソースをコピペして適当な名前を付けて保存

function createAndSendDocument() {
var sheetId = '上で調べたID';
var ss = SpreadsheetApp.openById(sheetId).getActiveSheet();
var docId = ss.getRange(1, 1, 2, 1);
Logger.log('docId: %s', docId.getValues()[1][0]);
var doc = null;
try{
doc = DocumentApp.openById(docId.getValues()[1][0]);
}catch(e){
doc = DocumentApp.create('_hello_world_');
docId.setValues([['docId'], [doc.getId()]]);
}
doc.getBody().appendParagraph('hello, ' + (new Date()).toISOString());
var url = doc.getUrl();
var subj = doc.getName();
doc.saveAndClose();
var email = Session.getActiveUser().getEmail();
var body = 'created: ' + url;
Logger.log('email: %s, subj: %s, url: %s, body: %s', email, subj, url, body);
GmailApp.sendEmail(email, subj, body);
}

保存出来たら [select function] で createAndSendDocument を選んで実行
2014/06/29(日) 16:28:54.93ID:tO69Jiz2
web で公開するには
とりあえず上のソースに次の関数を一つ追加しておいて
function doGet(e) {
createAndSendDocument();
return ContentService.createTextOutput(e && e.parameters.index ? e.parameters.index : '');
}
Script Editor で [Publish] -> [Deploy as web app...] を選択
ダイアログが出たら
Project Version: 適当な名前
(とりあえず [Save New Version] を押すとバージョン 1 が作られる)
Execute the app as: me (とりあえず自分だけに公開)
Who has access to the app: Only myself (とりあえず自分だけ ※)

※で Anyone を選んだときは Script 中で更新するファイルにあらかじめアクセス権の設定が別途必要

[your latest code] をクリックすると [***開発専用***の URL] が自動で開かれるので公開前のテストが出来る
[Deploy] を押すと [公開用の URL] が表示されるのでコピーして保存してあらためてブラウザでその URL にアクセス

さらに一度公開したものを更新するときはバージョン番号を上げる必要がある
具体的にはバージョン 2 以降は [Publish] -> [Deploy as web app..] を押す前に
Script Editor の [File] -> [Manage versions...] であらかじめ新しいバージョンを作る必要がある
2014/06/29(日) 17:48:16.55ID:5HmND7Qc
日記乙
参考になった
レスを投稿する

5ちゃんねるの広告が気に入らない場合は、こちらをクリックしてください。

ニューススポーツなんでも実況