Created
March 21, 2019 12:23
-
-
Save jirawatee/d7b2b5aac26a3d93a091e6628d36752f to your computer and use it in GitHub Desktop.
Imagemap message in LINE Messaging API
This file contains hidden or 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 request = require("request-promise"); | |
const LINE_MESSAGING_API = "https://api.line.me/v2/bot/message"; | |
const LINE_HEADER = { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer <CHANNEL-ACCESS-TOKEN>" | |
}; | |
exports.AdvanceMessage = functions.https.onRequest((req, res) => { | |
return request({ | |
method: "POST", | |
uri: `${LINE_MESSAGING_API}/push`, | |
headers: LINE_HEADER, | |
body: JSON.stringify({ | |
to: "<USER-ID>", | |
messages: [ | |
{ | |
type: "imagemap", | |
baseUrl: "https://charabizasia.files.wordpress.com/2017/07/main-1.jpg?w=1040", | |
altText: "This is an imagemap", | |
baseSize: { | |
width: 1040, | |
height: 623 | |
}, | |
video: { | |
originalContentUrl: "https://mokmoon.com/videos/Brown.mp4", | |
previewImageUrl: "https://linefriends.com/img/bangolufsen/img_og.jpg", | |
area: { | |
x: 260, | |
y: 155, | |
width: 540, | |
height: 360 | |
}, | |
externalLink: { | |
linkUri: "https://line.me", | |
label: "See More" | |
} | |
}, | |
actions: [ | |
{ | |
type: "uri", | |
linkUri: "https://developers.line.biz", | |
area: { | |
x: 0, | |
y: 0, | |
width: 320, | |
height: 320 | |
} | |
}, | |
{ | |
type: "message", | |
text: "Hello", | |
area: { | |
x: 720, | |
y: 303, | |
width: 320, | |
height: 320 | |
} | |
} | |
] | |
} | |
] | |
}) | |
}).then(() => { | |
return res.status(200).send("Done"); | |
}).catch(error => { | |
return Promise.reject(error); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment