Skip to content

Commit

Permalink
🎉 Support image HTTP / HTTPS
Browse files Browse the repository at this point in the history
  • Loading branch information
kittinan committed Dec 17, 2017
1 parent ffc1852 commit 759af2c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/LineNotify.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,21 @@ public function send($text, $imagePath = null, $sticker = null) {
'contents' => $text
]
];

if (!empty($imagePath)) {

if (!empty($imagePath) && preg_match("#^https?://#", $imagePath)) {
// Remote HTTP / HTTPS image
$request_params['multipart'][] = [
'name' => 'imageThumbnail',
'contents' => $imagePath
];

$request_params['multipart'][] = [
'name' => 'imageFullsize',
'contents' => $imagePath
];

} elseif (!empty($imagePath) && file_exists($imagePath)) {
// Local image
$request_params['multipart'][] = [
'name' => 'imageFile',
'contents' => fopen($imagePath, 'r')
Expand Down

0 comments on commit 759af2c

Please sign in to comment.