取得好友資訊
let lineUser = getLineUser(source.userId);
let botInfo = getLineBotInfo();
if (lineUser.displayName == '') {
let url = `https://line.me/R/ti/p/${botInfo.basicId}`;
//---------------------------------- flex(請加好友)
let messages = [{
"type": "flex",
"altText": "請加好友",//訊息副標題
"contents": errorFlexTemplate(url)
}];
lineReplyMessage(replyToken, messages);
return;
}
errorFlexTemplate
/*============================================
請加好友
https://developers.line.biz/flex-simulator/
https://line.me/R/ti/p/{basicId}
============================================*/
function errorFlexTemplate(url) {
let content = `點擊連結,請加好友`;
let messages = {
"type": "bubble",
"hero": {
"type": "image",
"url": "https://i.imgur.com/klNWUuY.png",//圖片
"size": "full",
"aspectRatio": "20:13",
"aspectMode": "cover"
},
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"text": "請加「好友」",//標題
"weight": "bold",
"size": "xl"
},
{
"type": "text",
"text": content,//內容
"wrap": true,
"color": "#666666",
"size": "sm",
},
{
"type": "button",
"style": "link",
"height": "sm",
"action": {
"type": "uri",
"label": "請加好友",
"uri": url
}
}
]
}
}
return messages;
}