Skip to content

Instantly share code, notes, and snippets.

@app2641
Last active Dec 31, 2015
Embed
What would you like to do?
ChatWorkAPI GoogleAppsScript Sample
function getCalendarSchedule () {
var calendar = CalendarApp.getCalendarsByName('予定')[0],
events = calendar.getEventsForDay(new Date()),
schedule = '';
for (var i = 0; i < events.length; i++) {
schedule += events[i].getTitle() + '\n';
}
return schedule;
}
function postChatWork (message) {
message = encodeURI(message);
try {
UrlFetchApp.fetch('https://api.chatwork.com/v1/rooms/{room_number}/message?body=' + body, {
method: 'POST',
headers: {'X-ChatWorkToken': 'chatwork_api_key'}
});
} catch (e) {
Logger.log(e);
}
}
function main () {
var schedule = getCalendarSchedule();
postChatWork('今日の予定\n' + schedule);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment