Last active
April 20, 2019 07:43
-
-
Save rch850/50a9ce7c039d514f47debb2cf932ba2c to your computer and use it in GitHub Desktop.
Google Apps Script which copies connpass events to spreadsheet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compiled using ts2gas 1.6.2 (TypeScript 3.4.4) | |
var exports = exports || {}; | |
var module = module || { exports: exports }; | |
//import { ConnpassEventsResponse } from "./connpass"; | |
// Connpass API: https://connpass.com/about/api/ | |
// | |
// 2400 is a series id of ふくもく会. | |
// Your series id can be revrieved by calling | |
// https://connpass.com/api/v1/event/?event_id=YOUR_EVENT_ID | |
var CONNPASS_SERIES_ID = 2400; | |
function syncEvents() { | |
var query = [ | |
"series_id=" + CONNPASS_SERIES_ID, | |
"count=100", | |
// 開催日時順 (2) | |
"order=2" | |
].join('&'); | |
var respObj = UrlFetchApp.fetch("https://connpass.com/api/v1/event/?" + query); | |
var resp = JSON.parse(respObj.getContentText()); | |
var cells = resp.events.map(function (event) { return ([ | |
event.title, | |
_formatDate(new Date(event.started_at)), | |
event.event_url, | |
event.place, | |
event.address | |
]); }); | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
sheet.getRange(2, 1, cells.length, 5).setValues(cells); | |
} | |
function _formatDate(date) { | |
return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment