node-red-contrib-line-messaging-api 0.1.15 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/nodes/_new/notify/notify.js +23 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,28 @@ AdminタブからInstall
|
|
|
46
46
|
|
|
47
47
|

|
|
48
48
|
|
|
49
|
+
### LINE Notify_new
|
|
50
|
+
|
|
51
|
+
過去のものとAPIは変わってないですが、オプション指定ができます。
|
|
52
|
+
|
|
53
|
+
> 
|
|
54
|
+
|
|
55
|
+
template nodeにJSONを設定してみてください。
|
|
56
|
+
|
|
57
|
+
> 
|
|
58
|
+
|
|
59
|
+
- 画像とスタンプも送る例
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
{
|
|
63
|
+
"stickerPackageId": "446",
|
|
64
|
+
"stickerId": "1988",
|
|
65
|
+
"message": "{{payload}}",
|
|
66
|
+
"imageThumbnail": "https://i.gyazo.com/a84c585225af440bd0d5fff881152792.png",
|
|
67
|
+
"imageFullsize": "https://i.gyazo.com/a84c585225af440bd0d5fff881152792.png"
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
49
71
|
## LINK
|
|
50
72
|
|
|
51
73
|
* [NodeRED](https://flows.nodered.org/node/node-red-contrib-line-messaging-api)
|
|
@@ -54,6 +76,7 @@ AdminタブからInstall
|
|
|
54
76
|
|
|
55
77
|
## release
|
|
56
78
|
|
|
79
|
+
- 2023/12/11: Notify_newを追加。スタンプや画像も送れるように。
|
|
57
80
|
- 2021/8/1: Reply Messageが画像に対応(thanks [@ukkz](https://github.com/ukkz))
|
|
58
81
|
- 2020/12/17: Bloadcast Messageに対応、Reply MessageがFlex Messageに対応(thanks [@gaomar](https://github.com/gaomar))
|
|
59
82
|
- 2019/2/13: PUSH MessageとLINE Notify対応
|
|
@@ -3,29 +3,39 @@ module.exports = (RED) => {
|
|
|
3
3
|
|
|
4
4
|
const LINE_NOTIFY_BASE_URL = 'https://notify-api.line.me';
|
|
5
5
|
const LINE_NOTIFY_PATH = '/api/notify';
|
|
6
|
-
let REQUEST_OPTIONS = {};
|
|
6
|
+
// let REQUEST_OPTIONS = {};
|
|
7
7
|
|
|
8
8
|
const main = function(config){
|
|
9
9
|
const node = this;
|
|
10
10
|
RED.nodes.createNode(node, config);
|
|
11
|
-
|
|
12
|
-
const LINE_NOTIFY_TOKEN = node.credentials.AccessToken;
|
|
13
|
-
REQUEST_OPTIONS = {
|
|
14
|
-
method: 'POST',
|
|
15
|
-
headers: {
|
|
16
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
17
|
-
'Authorization': `Bearer ${LINE_NOTIFY_TOKEN}`
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
11
|
|
|
22
12
|
/**
|
|
23
13
|
* 実行時の処理
|
|
24
14
|
*/
|
|
25
15
|
node.on('input', async (msg, send, done) => {
|
|
26
|
-
const
|
|
27
|
-
const REQUEST_URL = `${LINE_NOTIFY_BASE_URL}${LINE_NOTIFY_PATH}?message=${encodeURI(mes)}`;
|
|
16
|
+
// const REQUEST_URL = `${LINE_NOTIFY_BASE_URL}${LINE_NOTIFY_PATH}?message=${encodeURI(mes)}&stickerPackageId=1`;
|
|
28
17
|
try {
|
|
18
|
+
const REQUEST_URL = `${LINE_NOTIFY_BASE_URL}${LINE_NOTIFY_PATH}`;
|
|
19
|
+
const mes = msg.payload;
|
|
20
|
+
console.log(mes, typeof mes);
|
|
21
|
+
|
|
22
|
+
let params = {};
|
|
23
|
+
try {
|
|
24
|
+
params = JSON.parse(mes); // JSON形式の場合
|
|
25
|
+
} catch (error) {
|
|
26
|
+
params.message = mes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const LINE_NOTIFY_TOKEN = node.credentials.AccessToken;
|
|
30
|
+
const REQUEST_OPTIONS = {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
34
|
+
'Authorization': `Bearer ${LINE_NOTIFY_TOKEN}`
|
|
35
|
+
},
|
|
36
|
+
body: new URLSearchParams(params).toString()
|
|
37
|
+
};
|
|
38
|
+
|
|
29
39
|
const response = await fetch(REQUEST_URL, REQUEST_OPTIONS);
|
|
30
40
|
const data = await response.json();
|
|
31
41
|
msg.payload = data;
|