Skip to content

Commit 1cd53f0

Browse files
committed
Add MessageObject Functions and prepare add Message Features
1 parent ea58e89 commit 1cd53f0

File tree

2 files changed

+59
-4
lines changed

2 files changed

+59
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
line-bot-sdk-php-tiny
22
==
3-
[![License](https://img.shields.io/badge/license-Apache--2.0-FF3333.svg)](LICENSE) [![Line](https://img.shields.io/badge/lineapi-v2-00DD77.svg)](https://developers.line.me) ![Version](https://img.shields.io/badge/version-2.1-00BBFF.svg) ![PHP](https://img.shields.io/badge/php-5.x-B94FFF.svg)
3+
[![License](https://img.shields.io/badge/license-Apache--2.0-FF3333.svg)](LICENSE) [![Line](https://img.shields.io/badge/lineapi-v2-00DD77.svg)](https://developers.line.me) [![Version](https://img.shields.io/badge/version-2.2-00BBFF.svg)](https://github.com/supersonictw/line-bot-sdk-php-tiny) [![PHP](https://img.shields.io/badge/php-5.x-B94FFF.svg)](https://php.net)
44

5-
[![LINE](http://lineofficial.blogimg.jp/tw/imgs/2/2/22f62401.png)](https://line.me)
5+
[![LINE](https://lineofficial.blogimg.jp/tw/imgs/2/2/22f62401.png)](https://line.me)
66

77
A simple SDK for the LINE Messaging API for PHP.
88

@@ -11,7 +11,7 @@ Description
1111

1212
The origin version is [line-bot-sdk-tiny](https://github.com/line/line-bot-sdk-php/tree/master/line-bot-sdk-tiny) by LINE Corp.
1313

14-
The version of LINE Messaging API by [SuperSonic](https://github.com/supersonictw) as Third Party Update to support more LINE features.
14+
The version of LINE Messaging API by [SuperSonic](https://randychen.tk) as Third Party Update to support more LINE features.
1515

1616
The API has only a "api.php" file to include into your LINEBOT.
1717

api.php

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Third Party Update by SuperSonic
2929
====================================
3030
Copyright(c) 2018 Randy Chen. http://randychen.tk/
31-
Version: 2.1
31+
Version: 2.2
3232
More Information:
3333
https://github.com/supersonictw/line-bot-sdk-php-tiny
3434
*/
@@ -350,6 +350,50 @@ public function multicast($to, $message) {
350350
}
351351
}
352352

353+
public function getMessageObject($msgid) {
354+
$header = array(
355+
'Authorization: Bearer ' . $this->channelAccessToken,
356+
);
357+
358+
$context = stream_context_create(array(
359+
"http" => array(
360+
"method" => "GET",
361+
"header" => implode("\r\n", $header),
362+
),
363+
));
364+
365+
$response = file_get_contents($this->host."/v2/bot/message/".$msgid."/content", false, $context);
366+
if (strpos($http_response_header[0], '200') === false) {
367+
http_response_code(500);
368+
error_log("Request failed: " . $response);
369+
}else {
370+
return $response;
371+
}
372+
}
373+
374+
public function downloadMessageObject($msgid, $path = "./") {
375+
$header = array(
376+
'Authorization: Bearer ' . $this->channelAccessToken,
377+
);
378+
379+
$context = stream_context_create(array(
380+
"http" => array(
381+
"method" => "GET",
382+
"header" => implode("\r\n", $header),
383+
),
384+
));
385+
386+
$response = file_get_contents($this->host."/v2/bot/message/".$msgid."/content", false, $context);
387+
if (strpos($http_response_header[0], '200') === false) {
388+
http_response_code(500);
389+
error_log("Request failed: " . $response);
390+
}else {
391+
$file = fopen($path.$msgid, "wb");
392+
fwrite($file, $response);
393+
fclose($file);
394+
}
395+
}
396+
353397
private function sign($body) {
354398
$hash = hash_hmac('sha256', $body, $this->channelSecret, true);
355399
$signature = base64_encode($hash);
@@ -447,4 +491,15 @@ public function Flex($url, $contents = null) {
447491
}
448492
}
449493

494+
class LINEMSG_Imagemap {
495+
496+
}
497+
498+
class LINEMSG_Template {
499+
500+
}
501+
502+
class LINEMSG_FlexContainer {
503+
504+
}
450505
?>

0 commit comments

Comments
 (0)