@@ -25,7 +25,7 @@ public function getToken() {
25
25
return $ this ->token ;
26
26
}
27
27
28
- public function send ($ text , $ imagePath = null ) {
28
+ public function send ($ text , $ imagePath = null , $ sticker = null ) {
29
29
30
30
if (empty ($ text )) {
31
31
return false ;
@@ -36,20 +36,37 @@ public function send($text, $imagePath = null) {
36
36
'Authorization ' => 'Bearer ' . $ this ->token ,
37
37
],
38
38
];
39
+
40
+ //Message always required
41
+ $ request_params ['multipart ' ] = [
42
+ [
43
+ 'name ' => 'message ' ,
44
+ 'contents ' => $ text
45
+ ]
46
+ ];
39
47
40
48
if (!empty ($ imagePath )) {
41
- $ request_params ['multipart ' ] = [
42
- [
43
- 'name ' => 'message ' ,
44
- 'contents ' => $ text
45
- ],
46
- [
47
- 'name ' => 'imageFile ' ,
48
- 'contents ' => fopen ($ imagePath , 'r ' )
49
- ],
49
+ $ request_params ['multipart ' ][] = [
50
+ 'name ' => 'imageFile ' ,
51
+ 'contents ' => fopen ($ imagePath , 'r ' )
52
+ ];
53
+ }
54
+
55
+ //https://devdocs.line.me/files/sticker_list.pdf
56
+ if (!empty ($ sticker )
57
+ && !empty ($ sticker ['stickerPackageId ' ])
58
+ && !empty ($ sticker ['stickerId ' ])) {
59
+
60
+ $ request_params ['multipart ' ][] = [
61
+ 'name ' => 'stickerPackageId ' ,
62
+ 'contents ' => $ sticker ['stickerPackageId ' ]
63
+ ];
64
+
65
+ $ request_params ['multipart ' ][] = [
66
+ 'name ' => 'stickerId ' ,
67
+ 'contents ' => $ sticker ['stickerId ' ]
50
68
];
51
- } else {
52
- $ request_params ['form_params ' ] = ['message ' => $ text ];
69
+
53
70
}
54
71
55
72
$ response = $ this ->http ->request ('POST ' , LineNotify::API_URL , $ request_params );
0 commit comments