Skip to content

Instantly share code, notes, and snippets.

View tandevmode's full-sized avatar

Warit Wanwithu tandevmode

View GitHub Profile
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..."
}'
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"
}
],
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"
}
],
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());
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
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"
{
"destination": "xxxxxxxxxx",
"events": [
{
"replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
"type": "message",
"mode": "active",
"timestamp": 1462629479859,
"source": {
"type": "user",
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`
};
const functions = require('firebase-functions')
// สำหรับการเข้าถึง Cloud Storage
const admin = require("firebase-admin");
admin.initializeApp();
// สำหรับ network requests
const axios = require('axios');
// สำหรับสร้าง public url ใน Cloud Storage
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"
});