Skip to content

Commit

Permalink
- Support Sticker
Browse files Browse the repository at this point in the history
  • Loading branch information
kittinan committed Aug 13, 2017
1 parent a398b87 commit 51c3a38
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $ln->send($text, $image_path);
```

## Screenshot
![Screenshot](/screenshot/screen.png?raw=true "Screenshot")
![Screenshot](/screenshot/screen2.png?raw=true "Screenshot")


License
Expand Down
Binary file added screenshot/screen2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 29 additions & 12 deletions src/LineNotify.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getToken() {
return $this->token;
}

public function send($text, $imagePath = null) {
public function send($text, $imagePath = null, $sticker = null) {

if (empty($text)) {
return false;
Expand All @@ -36,20 +36,37 @@ public function send($text, $imagePath = null) {
'Authorization' => 'Bearer ' . $this->token,
],
];

//Message always required
$request_params['multipart'] = [
[
'name' => 'message',
'contents' => $text
]
];

if (!empty($imagePath)) {
$request_params['multipart'] = [
[
'name' => 'message',
'contents' => $text
],
[
'name' => 'imageFile',
'contents' => fopen($imagePath, 'r')
],
$request_params['multipart'][] = [
'name' => 'imageFile',
'contents' => fopen($imagePath, 'r')
];
}

//https://devdocs.line.me/files/sticker_list.pdf
if (!empty($sticker)
&& !empty($sticker['stickerPackageId'])
&& !empty($sticker['stickerId'])) {

$request_params['multipart'][] = [
'name' => 'stickerPackageId',
'contents' => $sticker['stickerPackageId']
];

$request_params['multipart'][] = [
'name' => 'stickerId',
'contents' => $sticker['stickerId']
];
} else {
$request_params['form_params'] = ['message' => $text];

}

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

0 comments on commit 51c3a38

Please sign in to comment.