コード.gs
function getTags() { var method = 'get'; var payload = null; var url = 'https://api.livechatinc.com/tags'; var response = getResponse(method, url, payload); Logger.log(response) } function postTag() { var method = 'post'; var tag = '追加タグ名'; var payload = { 'tag': tag, 'author': 'NAME@gmail.com', 'group': 0, } payload = JSON.stringify(payload); var url = 'https://api.livechatinc.com/tags'; var response = getResponse(method, url, payload); Logger.log(response) } function deleteTag() { var method = 'delete'; var tag = '追加タグ名'; var payload = { 'group': 0 } payload = JSON.stringify(payload); var url = 'https://api.livechatinc.com/tags' + '/' + tag; var response = getResponse(method, url, payload); Logger.log(response); } function getResponse(method, url, payload) { var options = { 'method': method, 'headers': { 'X-API-Version': 2, 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + getProp('token') }, 'payload': payload }; var response = UrlFetchApp.fetch(url, options); return response; } function getProp(key) { return PropertiesService.getScriptProperties().getProperty(key); } |
関連記事
LiveChatのアクセストークンを取得したい
LiveChat APIでタグの一覧を取得したい
LiveChat APIでタグを追加したい
LiveChat APIでタグを削除したい
参考
Tags
https://developers.livechatinc.com/docs/rest-api/#tags