// ลิงค์ liff id
// const btn = document.getElementById('btn');
const liffId = '1656372900-VM6wDmam';
let userId = '';

function main(){
    liff.init({liffId: liffId});
    // login
    liff.ready.then(() => {
        if(!liff.isLoggedIn()){
            liff.login();
        }
        // profile
        liff.getProfile().then(profile => {
            console.log(profile);
            // console.log(profile.userId);
            // console.log(profile.displayName);
            // console.log(profile.pictureUrl);
            // document.getElementById("userId").var(profile.userId);
            document.getElementById("pictureUrl").src = profile.pictureUrl;
            document.getElementById("userId").value = profile.userId;
            document.getElementById("displayName").value = profile.displayName;
            document.getElementById("statusMessage").value =  profile.statusMessage;

            // สร้างตัวแปร
            var userId = profile.userId;
            console.log(userId);

            // ส่งข้อมูล ผ่าน ajax
            $.ajax({
                type:"GET",
                url:"ajax/data_ajax.php",
                data: "lineid=" + profile.userId,
                success: function(data) {
                    $("#get_datauser").html(data);
                },
            });
        })
    });
}
main()
