Line

Line Notify

āļŠāđˆāļ‡āļĢāļđāļ›āļ āļēāļžāļŦāļĨāļēāļĒ āđ† āļĢāļđāļ›āļžāļĢāđ‰āļ­āļĄāļāļąāļ™

// Presented by BrilliantPy.com
 
function sendLineNotify() {
   
    // Editable
    var form = FormApp.openById('11Vl5RpalZ6IWdquI9CeXRrlrxmhTIPO-11Vl5RpalZ6'); 
    var tokens = ['WNFKVX1uXhfAqwLCIPxHiAWNFKVX1uXhfAqwLCIPxHiA']; // For 1 line group
    //var tokens = ['WNFKVX1uXhfAqwLCIPxHiAWNFKVX1uXhfAqwLCIPxHiA','WNFKVX1uXhfAqwLCIPxHiAWNFKVX1uXhfAqwLCIPxHiA']; // For multiple line groups
     
    // Init
    var form_res = form.getResponses()
    var formResponse = form_res[form_res.length - 1];
    var itemResponses = formResponse.getItemResponses();
     
    // Gets an array of all items in the form.
    var items = form.getItems();
    var all_message = form.getTitle() + '\n';
    var all_message_resend = '';
    var all_message_send = '';
    var image_id = [];
    var IMAGE_URL = [];
    var imgThumbnail = [];
    var imgFullsize =  [];
    var file_upload_num = 0;
     
    for (var i = 0; i < itemResponses.length; i++) 
    {
      if (itemResponses[i].getItem().getType() == "GRID") 
      {
        var mrow = items[i].asGridItem().getRows();
        var mcol = items[i].asGridItem().getColumns();
        var itemResponse_val = itemResponses[i].getResponse().toString().split(",")
         
        all_message += (i+1) + ') ' + itemResponses[i].getItem().getTitle() + ' : ' + '\n';
         
        for (var j = 0; j < mrow.length; j++)
        {
          all_message += '   - ' + mrow[j] + ' : ' + itemResponse_val[j] + '\n';
        }
      }
      else if (itemResponses[i].getItem().getType() == "FILE_UPLOAD")
      {
        image_id[file_upload_num] = itemResponses[i].getResponse()
        IMAGE_URL[file_upload_num] = 'https://drive.google.com/uc?export=view&id='+ image_id[file_upload_num];
        imgThumbnail[file_upload_num] = IMAGE_URL[file_upload_num]; // 240×240px JPEG
        imgFullsize[file_upload_num] = IMAGE_URL[file_upload_num]; //1024×1024px JPEG
        //all_message += (i+1) + ') ' + itemResponses[i].getItem().getTitle() + ' : ' + 'As below' + '\n';
        all_message += (i+1) + ') ' + itemResponses[i].getItem().getTitle() + ' : ' + IMAGE_URL[file_upload_num] + '\n';
        file_upload_num += 1;
      }
      else
      {
        all_message += (i+1) + ') ' + itemResponses[i].getItem().getTitle() + ' : ' + itemResponses[i].getResponse() + '\n';
      }
    }
     
    all_message_send = all_message;
    
    for (var k = 0; k < tokens.length; k++) {
      if ( file_upload_num > 0 ) 
      {
        for (var m = 0; m < file_upload_num; m++ )
        {
          if ( m == 0 )
          {
            all_message_send = all_message;
          }
          else if ( m > 0 ) 
          {
            all_message_resend = 'Picture: ' + (m+1);
            all_message_send = all_message_resend;
          }
          var formData = {
            'message' : all_message_send,
            'imageThumbnail': imgThumbnail[m],'imageFullsize' : imgFullsize[m],   
          }
           
          var options = {
            "method" : "post",
            "payload" : formData,
            "headers" : {"Authorization" : "Bearer " + tokens[k]}
          };
          UrlFetchApp.fetch("https://notify-api.line.me/api/notify", options);
        }
      }
      else {
        var formData = {
          'message' : all_message_send,  
        }
         
        var options = {
          "method" : "post",
          "payload" : formData,
          "headers" : {"Authorization" : "Bearer " + tokens[k]}
        };
        UrlFetchApp.fetch("https://notify-api.line.me/api/notify", options);
      }
    }
  }

Reference : https://brilliantpy.com/2020/12/01/send_data_from_google_sheet_to_line_notify/

Emoji

  • emoji(Unicode emoji āđāļĨāļ° LINE emoji) āđ‚āļ”āļĒāļĢāļ°āļšāļļāđ„āļ”āđ‰āļŠāļđāļ‡āļŠāļļāļ” 2,000 āļ•āļąāļ§āļ­āļąāļāļĐāļĢ

āļŦāļĄāļēāļĒāđ€āļŦāļ•āļļ: Code āļ—āļĩāđˆāđāļŠāļ”āļ‡āđƒāļ™ LINE emoji āļ„āļ·āļ­ Hex code point āļ‹āļķāđˆāļ‡āđ€āļĢāļēāļˆāļ°āļ•āđ‰āļ­āļ‡āđāļ›āļĨāļ‡āđƒāļŦāđ‰āļ­āļĒāļđāđˆāđƒāļ™āļĢāļđāļ›āđāļšāļšāļ‚āļ­āļ‡ Hex UTF-16 Surrogates āļāđˆāļ­āļ™āļ™āļģāđ„āļ›āđƒāļŠāđ‰ āđ‚āļ”āļĒāļŠāļēāļĄāļēāļĢāļ–āđāļ›āļĨāļ‡āđ„āļ”āđ‰āļ—āļĩāđˆāđ€āļ§āđ‡āļš http://www.ltg.ed.ac.uk/~richard/utf-8.cgi

var msg = "\uDBC0\uDC49 This Holiday Season, get 30% off all products \uD83C\uDF84"

sendLineNotify(msg,tokens);

function sendLineNotify(msg,tokens) {   

    var picURL = 'http://drive.google.com/uc?export=view&id='+url;     
    
    var formData = {     
    'message' : msg,       
    'imageThumbnail': picURL,
    'imageFullsize' : picURL}
    var options = {
    "method" : "post",
    "payload" : formData,
    "headers" : {"Authorization" : "Bearer " + tokens}};
      UrlFetchApp.fetch("https://notify-api.line.me/api/notify", options);
}}

Last updated