-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.html
181 lines (181 loc) · 5.33 KB
/
mod.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LIFF-mod</title>
<link href="./style.css" rel="stylesheet">
<link rel="icon" href="https://obs.line-scdn.net/0hrKkn3t_FLWRWFz-5ynlSMwRKJgZldTNvdCM5AzZocTAzTAxSbw8baSxCGjAzcghZIRAEQzVoAT96RgxSNiQHAzp_FTB6TBxzLSQXcjhEBiQ9XDZoYg0S"/>
</head>
<body>
<h2>LIFF-mod Document</h2>
<p>Err : <br><span id="err"></span>
</p>
<p>src="https://liff-tool.f5.si/mod.js"</p>
<h3>初期化・認証</h3>
<h4>liffmod.init()</h4>
<p>LIFFアプリを初期化します。このメソッドを実行すると、LIFF modの他のメソッドを実行できるようになります。</p>
<pre>
liffmod.init()
// liffIdは必要ありません
.then(() => {
// Start to use liff's api
})
.catch((err) => {
// Error happens during initialization
console.log(err);
})
</pre>
<h4>liffmod.setAccessToken(token)</h4>
<p>AccessTokenを変更します。不正なtokenは設定できません。</p>
<pre>
liffmod.setAccessToken(token)
.then(() => {
// Start to use liff's api
})
.catch((err) => {
// Error happens during initialization
console.log(err);
})
</pre>
<h4>liffmod.isToken(token)</h4>
<p>tokenが正しいtokenかを返します</p>
<pre>
liffmod.isToken(token)
.then((res)=>{ //true or false
if (res){
console.log("ok")
}
})
</pre>
<h3>情報の取得</h3>
<h4>liffmod.context</h4>
<p>liff.getContext()と同じ値を返します。liffmod.createURL()で生成したurlでは、liffId,scope,userId,type,squareMemberIdのみ利用可能です。</p>
<pre>
const context = liffmod.context;
console.log(context);
</pre>
<h4>liffmod.getContext(token,isChange)</h4>
<p>init前に取得する場合に使用します。contextTokenを指定してtokenから取得することもできます。tokenを設定した場合isChangeをtrueにするとliffmod.contextも変更できます。</p>
<pre>
liffmod.getContext()
.then((context) => {
console.log(context)
})
.catch((err) => {
console.log("error", err);
});
</pre>
<h4>liffmod.hash.getContextToken()</h4>
<p>hashから取得したContextTokenを返します。</p>
<pre>
const context = liffmod.hash.getContextToken();
console.log(context);
</pre>
<h4>liffmod.accessToken</h4>
<p>liff.getAccessToken()と同じ値を返します。</p>
<pre>
const accessToken = liffmod.accessToken;
console.log(accessToken);
</pre>
<h4>liffmod.hash.getAccessToken()</h4>
<p>hashから取得したAccessTokenを返します。setAccessTokenで変更した場合は変更前のtokenになります。</p>
<pre>
const accessToken = liffmod.hash.getAccessToken();
console.log(accessToken);
</pre>
<h4>liffmod.getProfile()</h4>
<p>liff.getProfile()と同じ値を返します。取得したプロフィールはliffmod.profileからも利用可能です。
</p>
<pre>
liffmod
.getProfile()
.then((profile) => {
const name = profile.displayName;
console.log(name)
})
.catch((err) => {
console.log("error", err);
});
</pre>
<h3>メッセージ送信</h3>
<h4>liffmod.sendMessages(msg)</h4>
<p>liff.sendMessages()と同じ挙動をします。</p>
<pre>
liffmod.sendMessages([
{
type: "text",
text: "Hello, World!",
},
])
.then(() => {
console.log("message sent");
})
.catch((err) => {
console.log("error", err);
});
</pre>
<h3>token機能</h3>
<h4>liffmod.token.sendMessages(msg,token)</h4>
<p>tokenを指定してメッセージ送信ができます。</p>
<pre>
liffmod.token.sendMessages([
{
type: "text",
text: "Hello, World!",
},
],token)
.then(() => {
console.log("message sent");
})
.catch((err) => {
console.log("error", err);
});
</pre>
<h4>liffmod.token.getProfile(token)</h4>
<p>tokenからプロフィールが取得できます。
</p>
<pre>
liffmod
.getProfile(token)
.then((profile) => {
const name = profile.displayName;
console.log(name)
})
.catch((err) => {
console.log("error", err);
});
</pre>
<h3>パーマネントリンク</h3>
<h4>liffmod.createURL()</h4>
<p>開いているページのtoken付きurlを生成します。生成したurlは外部ブラウザ等からのメッセージ送信に使えます。</p>
<pre>
liffmod.createURL()
.then((url)=>open(url))
</pre>
<button onclick=sharelink()>token共有</button>
<br><p><a href="https://line.me/R/oaMessage/@228jbgfo/">バグ報告・質問等はこちらへ</a></p>
<script src="./mod.js"></script>
<script>
function htmlErr(p) {
document.getElementById("err").innerHTML=p
}
liffmod.init();
function sharelink() {
liffmod.createURL().then(
(url)=>{
return encodeURIComponent(url)}
).then((uri)=>{
liffmod.sendMessages([
{
type: "text",
text: uri,
},
])
open("line://share?text="+uri)})
}
</script>
</body>
</html>