Line 自訂分享訊息

<input id="msg_data" type="text" class="form-control " value=""  />
<button onclick="sendLine();">傳Line</button>
function sendLine(){
    var msg = $( "#chat_msg_data" ).val();
    var encoded = encodeURIComponent(msg);
    if(encoded){
        window.location.replace("https://line.me/R/share?text="+encoded );
    }else{
        alert('請輸入訊息');
    }
}

1.文字內容務必urlencode過
2.傳送網址格式可以用
https://line.me/R/share?text={text_message}

https://line.me/R/msg/text/?{text_message}

更多功能可以參考

https://developers.line.biz/en/docs/line-login/using-line-url-scheme/#available-line-url-schemes