Skip to content

Instantly share code, notes, and snippets.

@r3-yamauchi
Created February 23, 2019 09:59
Show Gist options
  • Save r3-yamauchi/7b3d85901568891768131bc2feb2ae57 to your computer and use it in GitHub Desktop.
Save r3-yamauchi/7b3d85901568891768131bc2feb2ae57 to your computer and use it in GitHub Desktop.
LIFF を使って LINE から簡単に kintone データにアクセスする
const app = new Vue({
el: '#app',
data: {
message: "こんにちは",
userId: "",
displayName: "",
accessToken: "",
scope: "",
client_id: "",
expires_in: ""
},
created() {
const that = this;
liff.init(
data => {
that.userId = data.context.userId;
that.message = "初期化できたし";
return liff.getProfile()
.then(profile => {
that.message = "プロフィール採れたし";
that.userId = profile.userId;
that.displayName = profile.displayName;
const accessToken = liff.getAccessToken();
if (!accessToken) {
that.message = "アクセストークンを取得できません";
return;
}
that.accessToken = accessToken;
that.message = "トークン採れたし";
return axios({
method: "POST",
url: 'サーバーのURL',
data: {},
headers: {
'Content-Type': 'application/json',
'accessToken': accessToken
}
}).then(response => {
that.message = "完了";
});
})
.catch(err => {
that.message = "Error\n" + err.code + "\n" + err.message;
});
},
err => {
that.message = "Error\n" + err.code + "\n" + err.message;
}
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment