This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -v -X POST https://api.line.me/v2/bot/message/narrowcast \ | |
-H 'Authorization: Bearer {channel access token}' \ | |
-H 'Content-Type: application/json' \ | |
-d '{ | |
"messages": [ | |
{ | |
"type": "text", | |
"text": "Hello from Narrowcast API using audience from API and LINE OA Manager" | |
} | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -v -X POST https://api.line.me/v2/bot/message/narrowcast \ | |
-H 'Authorization: Bearer {channel access token}' \ | |
-H 'Content-Type: application/json' \ | |
-d '{ | |
"messages": [ | |
{ | |
"type": "text", | |
"text": "Hello from Narrowcast API na ja" | |
} | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -v -X POST https://api.line.me/v2/bot/audienceGroup/imp \ | |
-H 'Authorization: Bearer {channel access token}' \ | |
-H 'Content-Type: application/json' \ | |
-d '{ | |
"description": "podcastEP1Imp", | |
"requestId": "c90d2f4b-24cc-4cbe-a7f1-d6c..." | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -v -X POST https://api.line.me/v2/bot/audienceGroup/click \ | |
-H 'Authorization: Bearer {channel access token}' \ | |
-H 'Content-Type: application/json' \ | |
-d '{ | |
"description": "podcastEP1click", | |
"requestId": "eec21aab-5747-41fe-95bc-ff7...", | |
"clickUrl": "https://open.spotify.com/episode/1NIfGNFe2DvymxTx5nofnA" | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -v -X POST https://api.line.me/v2/bot/audienceGroup/upload \ | |
-H 'Authorization: Bearer {channel access token}' \ | |
-H 'Content-Type: application/json' \ | |
-d '{ | |
"description": "regularCustomerGroup", | |
"isIfaAudience": "false", | |
"audiences":[ | |
{ | |
"id":"Uc0a294155281..." | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require("firebase-functions"); | |
const admin = require('firebase-admin'); | |
admin.initializeApp(); | |
const request = require("request-promise"); | |
const crypto = require('crypto'); | |
const runtimeOpts = { timeoutSeconds: 4, memory: "2GB" }; | |
const REGION = "asia-northeast1"; | |
const LINE_MESSAGING_API = "https://api.line.me/v2/bot/message"; | |
const LINE_CHANNEL_SECRET = "Your-Channel-Secret"; | |
const GROUP_ID = "Caf6..."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.LineBotPush = functions.region(REGION).runWith(runtimeOpts).firestore.document('translations/inputText').onWrite(async (change, context) => { | |
let latest = change.after.data(); | |
let input = latest.input; | |
let containsJapanese = input.match(/[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff00-\uff9f\u4e00-\u9faf\u3400-\u4dbf]/); | |
if (containsJapanese) { | |
push(GROUP_ID, latest.translated.th); | |
} else { | |
push(GROUP_ID, latest.translated.ja); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.LineWebhook = functions.region(REGION).runWith(runtimeOpts).https.onRequest(async (req, res) => { | |
let event = req.body.events[0]; | |
if (event.message.type === 'text') { | |
let input = event.message.text; | |
await admin.firestore().collection('translations').doc('inputText').set({ | |
input: input | |
}).then(function () { | |
console.log("Document successfully written!"); | |
}).catch(function (error) { | |
console.error("Error writing document: ", error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>My LIFF App</title> | |
</head> | |
<body> | |
<p id="scanCode"></p> | |
<p> | |
<button id="btnScanCode" onclick="scanCode();">Scan Code</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "b1fd7946.f6a0c8", | |
"type": "http in", | |
"z": "9295d104.785ef", | |
"name": "", | |
"url": "/playground/api", | |
"method": "post", | |
"upload": false, | |
"swaggerDoc": "", |