8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GASでLINE Notifyする関数メモ

Last updated at Posted at 2020-12-10

最近はGASがNode.jsのランタイムになったということでほぼ通常のJavaScriptと同様の書き方でいけますね。console.logとか

GASはよく使う訳じゃ無いけど、たまにコピペして使いたいときがあるのでメモっておきます。

関数

//LINE NotifyにPOST
function lineNotify(postText){
  try {
    const url  = 'https://notify-api.line.me/api/notify'
    const token = ''; //LINE NotifyのToken
    const params = {
      method: 'post',
      headers: {
        'Authorization': 'Bearer '+ token
      },
      payload: {
        message : postText
      }
    }
   
   const res = UrlFetchApp.fetch(url, params);
   console.log(res);
    
  } catch (error) {
    
    console.log(error);
    
  }
}

使う時

lineNotify('送信するメッセージ');

おまけ

こんな感じで関数ごとにファイル作っておくと管理しやすいです。

スクリーンショット 2020-12-10 23.39.56.png

8
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?