function getProfile() { liff .getProfile() .then(profile => { console.log(JSON.stringify(profile)); window.alert(JSON.stringify(profile)); }) .catch(e => { console.log(e); window.alert(e); }); } function getAccessToken() { window.alert(liff.getAccessToken()); } function getContext() { window.alert(JSON.stringify(liff.getContext())); } function sendMessage() { liff .sendMessages([{ type: "text", text: "中文測試 Hello from LIFF2.0" }]) .then(() => { window.alert("Message has been sent"); }) .catch(e => { window.alert(e); }); } function login() { liff.login(); } function scanCode() { liff .scanCode() .then(result => { window.alert(JSON.stringify(result)); }) .catch(e => { window.alert(e); }); } function openWindow() { liff.openWindow({ url: "https://sirateek.me", external: true }); } function closeWindow() { liff.closeWindow(); } function logout() { if (liff.isLoggedIn()) { liff.logout(); window.alert("Successfully to Logout"); location.reload(); } } function createFlexMessageData() { var myFlexContent = { "type": "bubble", "size": "mega", "header": { "type": "box", "layout": "vertical", "contents": [ { "type": "box", "layout": "vertical", "contents": [ { "type": "text", "text": "ChoozMo x 引新聞", "color": "#ffffff66", "size": "sm" }, { "type": "text", "text": "AI主播新聞曝光服務", "color": "#ffffff", "size": "xl", "flex": 4, "weight": "bold" } ] } ], "paddingAll": "20px", "backgroundColor": "#0367D3", "spacing": "md", "height": "100px", "paddingTop": "22px" }, "body": { "type": "box", "layout": "vertical", "contents": [ { "type": "image", "url": "https://img.youtube.com/vi/K5DEJXajtqA/0.jpg", "size": "full", "aspectRatio": "16:9", "aspectMode": "cover", "margin": "none", "offsetTop": "none" }, { "type": "text", "text": "以集仕多為例。您也能享有同等級曝光。", "color": "#b7b7b7", "size": "xs" }, { "type": "box", "layout": "horizontal", "contents": [ { "type": "image", "url": "https://s.yimg.com/rz/p/yahoo_news_zh-Hant-TW_h_p_newsv2.png", "margin": "xs" }, { "type": "box", "layout": "vertical", "contents": [], "flex": 0 }, { "type": "text", "text": "線上活動不受疫情影響 逆勢催生台灣元宇宙策展創新服務", "gravity": "center", "flex": 4, "size": "sm", "wrap": true } ], "spacing": "xs", "cornerRadius": "30px", "margin": "xl", "action": { "type": "uri", "label": "action", "uri": "https://tw.news.yahoo.com/%E7%B7%9A%E4%B8%8A%E6%B4%BB%E5%8B%95%E4%B8%8D%E5%8F%97%E7%96%AB%E6%83%85%E5%BD%B1%E9%9F%BF-%E9%80%86%E5%8B%A2%E5%82%AC%E7%94%9F%E5%8F%B0%E7%81%A3%E5%85%83%E5%AE%87%E5%AE%99%E7%AD%96%E5%B1%95%E5%89%B5%E6%96%B0%E6%9C%8D%E5%8B%99-035234457.html" } }, { "type": "box", "layout": "horizontal", "contents": [ { "type": "image", "url": "https://cc.tvbs.com.tw/img/upload/2021/03/03/20210303100057-83c4f845.png", "margin": "xs" }, { "type": "box", "layout": "vertical", "contents": [], "flex": 0 }, { "type": "text", "text": "疫情催生元宇宙策展創新服務 VR觀展全新體驗", "gravity": "center", "flex": 4, "size": "sm", "wrap": true } ], "spacing": "xs", "cornerRadius": "30px", "margin": "xl", "action": { "type": "uri", "label": "action", "uri": "https://news.tvbs.com.tw/life/1783151" } }, { "type": "box", "layout": "horizontal", "contents": [ { "type": "image", "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/LINE_logo.svg/2048px-LINE_logo.svg.png", "margin": "xs" }, { "type": "box", "layout": "vertical", "contents": [], "flex": 0 }, { "type": "text", "text": "線上活動不受疫情影響 逆勢催生台灣元宇宙策展創新服務", "gravity": "center", "flex": 4, "size": "sm", "wrap": true } ], "spacing": "xs", "cornerRadius": "30px", "margin": "xl", "action": { "type": "uri", "label": "action", "uri": "https://today.line.me/tw/v2/article/gzBJpea" } } ], "offsetTop": "none" },"footer": { "type": "box", "layout": "vertical", "contents": [ { "type": "text", "text": "幫您的產品服務在Yahoo, LINE today, TVBS, Pchome 等12個媒體曝光", "wrap": true, "color": "#AAAAAA", "size": "xs", "offsetStart": "md" }, { "type": "button", "action": { "type": "uri", "label": "請來採訪我", "uri": "https://page.line.me/choozmo" }, "style": "primary" } ] } }; var flex = { "type": "flex", "altText": 'title', "contents": myFlexContent, }; return flex; } function shareTargetPicker() { liff .shareTargetPicker([ createFlexMessageData() ]) .then(() => { // alert("Shared to the friend(s) you picked"); }) .catch(function(res) { alert(res); }); }