Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 51c3a38

Browse files
committed
- Support Sticker
1 parent a398b87 commit 51c3a38

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ $ln->send($text, $image_path);
4747
```
4848

4949
## Screenshot
50-
![Screenshot](/screenshot/screen.png?raw=true "Screenshot")
50+
![Screenshot](/screenshot/screen2.png?raw=true "Screenshot")
5151

5252

5353
License

Diff for: screenshot/screen2.png

134 KB
Loading

Diff for: src/LineNotify.php

+29-12
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function getToken() {
2525
return $this->token;
2626
}
2727

28-
public function send($text, $imagePath = null) {
28+
public function send($text, $imagePath = null, $sticker = null) {
2929

3030
if (empty($text)) {
3131
return false;
@@ -36,20 +36,37 @@ public function send($text, $imagePath = null) {
3636
'Authorization' => 'Bearer ' . $this->token,
3737
],
3838
];
39+
40+
//Message always required
41+
$request_params['multipart'] = [
42+
[
43+
'name' => 'message',
44+
'contents' => $text
45+
]
46+
];
3947

4048
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']
5068
];
51-
} else {
52-
$request_params['form_params'] = ['message' => $text];
69+
5370
}
5471

5572
$response = $this->http->request('POST', LineNotify::API_URL, $request_params);

0 commit comments

Comments
 (0)