Q&A

How can I get the number of followers (one of the insight properties) with Google-app-script linebot?

I want to get the number of followers of my official account with a Google-app-script-made line bot in order to record it in a googlesheet. Here is part of my code:

if (messageText == "abc") { replyMsg(replyToken, [{ "type": "text", "text": "The insight is" + insight(channelToken, 20220101).followers }] , channelToken); }

function replyMsg(replyToken, userMsg, channelToken) { var url = 'https://api.line.me/v2/bot/message/reply'; var opt = { 'headers': { 'Content-Type': 'application/json; charset=UTF-8', 'Authorization': 'Bearer ' + channelToken, }, 'method': 'post', 'payload': JSON.stringify({ 'replyToken': replyToken, 'messages': userMsg }) }; UrlFetchApp.fetch(url, opt); }

function insight (channelToken, date) { var url = 'https://api.line.me/v2/bot/insight/followers?date={' + date + '}'; var opt = { 'headers': { //'Content-Type': 'application/json; charset=UTF-8', 'Authorization': 'Bearer ' + channelToken, } }; UrlFetchApp.fetch(url, opt); }

Obviously it doesn't work correctly. How can I solve it? Thank you.

  • 0
  • 1
  • 459
  • twitter facebook

You don't have to use '{' and '}' in the url. https://developers.line.biz/en/reference/messaging-api/#get-insight

  • 0

関連する質問

    関連する質問はありません

本当によろしいですか? question.vm