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/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/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
const dotenv = require("dotenv"); | |
dotenv.config(); | |
const express = require("express"); | |
const lineApp = require("./lineapp"); | |
const spotify = require("./spotify"); | |
const bodyParser = require("body-parser"); | |
const app = express(); | |
app.use(bodyParser.json()); |
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 SpotifyWebApi = require("spotify-web-api-node"); | |
class Spotify { | |
constructor() { | |
// Init การเชื่อมต่อกับ Spotify | |
this.api = new SpotifyWebApi({ | |
clientId: process.env.SPOTIFY_CLIENT_ID, | |
clientSecret: process.env.SPOTIFY_CLIENT_SECRET, | |
redirectUri: process.env.SPOTIFY_CALLBACK |
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 spotify = require("./spotify"); | |
const request = require("request-promise"); | |
const LINE_HEADER = { | |
"Content-Type": "application/json", | |
Authorization: "Bearer " + process.env.LINE_ACCESS_TOKEN | |
} | |
const Commands = { | |
ADD_TRACK: "ADD_TRACK", | |
SEARCH_MORE: "SEARCH_MORE" |
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
{ | |
"destination": "xxxxxxxxxx", | |
"events": [ | |
{ | |
"replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA", | |
"type": "message", | |
"mode": "active", | |
"timestamp": 1462629479859, | |
"source": { | |
"type": "user", |
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 express = require("express"); | |
const bodyParser = require("body-parser"); | |
const crypto = require('crypto'); | |
const request = require("request-promise"); | |
const LINE_MESSAGING_API = 'https://api.line.me/v2/bot/message'; | |
const LINE_CHANNEL_SECRET = 'XXXXXXXXXXXXX'; | |
const LINE_HEADER = { | |
'Content-Type': 'application/json', | |
'Authorization': `Bearer XXXXXXXXXXXXXXXXXXX` | |
}; |
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') | |
// สำหรับการเข้าถึง Cloud Storage | |
const admin = require("firebase-admin"); | |
admin.initializeApp(); | |
// สำหรับ network requests | |
const axios = require('axios'); | |
// สำหรับสร้าง public url ใน Cloud Storage |
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 uploadAndProcessImg = async (event, city) => { | |
// ดึงรูปของผู้ใช้ที่ส่งมาจาก LINE | |
const url = `${LINE_CONTENT_API}/${event.message.id}/content`; | |
const originalImage = await axios({ | |
method: "get", | |
headers: LINE_HEADER, | |
url: url, | |
responseType: "arraybuffer" | |
}); |