Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ You can call an API through the messagingApi instance.
A very simple example:

```php
$message = new TextMessage(['type' => 'text','text' => 'hello!']);
$message = new TextMessage(['text' => 'hello!']);
$request = new ReplyMessageRequest([
'replyToken' => '<reply token>',
'messages' => [$message],
Expand All @@ -71,7 +71,6 @@ We also support setter style.

```php
$message = (new TextMessage())
->setType(\LINE\Constants\MessageType::TEXT)
->setText('hello!');
$request = (new ReplyMessageRequest)
->setReplyToken('<reply token>')
Expand All @@ -92,7 +91,7 @@ You may need to store the `x-line-request-id` header obtained as a response from
```php
$request = new ReplyMessageRequest([
'replyToken' => $replyToken,
'messages' => [$textMessage = (new TextMessage(['text' => 'reply with http info', 'type' => MessageType::TEXT]))],
'messages' => [$textMessage = (new TextMessage(['text' => 'reply with http info']))],
]);
$response = $messagingApi->replyMessageWithHttpInfo($request);
$this->logger->info('body:' . $response[0]);
Expand Down
2 changes: 1 addition & 1 deletion examples/EchoBot/src/LINEBot/EchoBot/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function register(\Slim\App $app)
$bot->replyMessage(new ReplyMessageRequest([
'replyToken' => $event->getReplyToken(),
'messages' => [
(new TextMessage(['text' => $replyText]))->setType('text'),
(new TextMessage(['text' => $replyText])),
],
]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use LINE\Clients\MessagingApi\Api\MessagingApiApi;
use LINE\Clients\MessagingApi\Model\ReplyMessageRequest;
use LINE\Clients\MessagingApi\Model\TextMessage;
use LINE\Constants\MessageType;
use LINE\Webhook\Model\AccountLinkEvent;

class AccountLinkEventHandler
Expand Down Expand Up @@ -56,7 +55,6 @@ public function handle()
'replyToken' => $this->accountLinkEvent->getReplyToken(),
'messages' => [
new TextMessage([
'type' => MessageType::TEXT,
'text' => 'Got account link event ' . $link->getNonce(),
]),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use LINE\Clients\MessagingApi\Api\MessagingApiApi;
use LINE\Clients\MessagingApi\Model\ReplyMessageRequest;
use LINE\Clients\MessagingApi\Model\TextMessage;
use LINE\Constants\MessageType;
use LINE\LINEBot\KitchenSink\EventHandler;
use LINE\Webhook\Model\BeaconEvent;

Expand Down Expand Up @@ -55,7 +54,7 @@ public function handle()
$request = new ReplyMessageRequest([
'replyToken' => $this->beaconEvent->getReplyToken(),
'messages' => [
new TextMessage(['type' => MessageType::TEXT, 'text' => 'Got beacon message ' . $this->beaconEvent->getHwid()]),
new TextMessage(['text' => 'Got beacon message ' . $this->beaconEvent->getHwid()]),
],
]);
$this->bot->replyMessage($request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use LINE\Clients\MessagingApi\Api\MessagingApiApi;
use LINE\Clients\MessagingApi\Model\ReplyMessageRequest;
use LINE\Clients\MessagingApi\Model\TextMessage;
use LINE\Constants\MessageType;
use LINE\LINEBot\KitchenSink\EventHandler;
use LINE\Webhook\Model\FollowEvent;

Expand Down Expand Up @@ -55,7 +54,7 @@ public function handle()
$request = new ReplyMessageRequest([
'replyToken' => $this->followEvent->getReplyToken(),
'messages' => [
new TextMessage(['type' => MessageType::TEXT, 'text' => 'Got followed event']),
new TextMessage(['text' => 'Got followed event']),
],
]);
$this->bot->replyMessage($request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use LINE\Clients\MessagingApi\Api\MessagingApiApi;
use LINE\Clients\MessagingApi\Model\ReplyMessageRequest;
use LINE\Clients\MessagingApi\Model\TextMessage;
use LINE\Constants\MessageType;
use LINE\LINEBot\KitchenSink\EventHandler;
use LINE\Webhook\Model\GroupSource;
use LINE\Webhook\Model\JoinEvent;
Expand Down Expand Up @@ -69,7 +68,6 @@ public function handle()
'replyToken' => $this->joinEvent->getReplyToken(),
'messages' => [
new TextMessage([
'type' => MessageType::TEXT,
'text' => sprintf('Joined %s %s', $this->joinEvent->getType(), $id),
]),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use LINE\Clients\MessagingApi\Api\MessagingApiApi;
use LINE\Clients\MessagingApi\Model\ReplyMessageRequest;
use LINE\Clients\MessagingApi\Model\TextMessage;
use LINE\Constants\MessageType;
use LINE\LINEBot\KitchenSink\EventHandler;
use LINE\Webhook\Model\GroupSource;
use LINE\Webhook\Model\MemberJoinedEvent;
Expand Down Expand Up @@ -74,7 +73,6 @@ public function handle()
'replyToken' => $this->memberJoinedEvent->getReplyToken(),
'messages' => [
new TextMessage([
'type' => MessageType::TEXT,
'text' => sprintf('%s joined. %s %s', implode(", ", $joinedMemberIds), $this->memberJoinedEvent->getType(), $id),
]),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
use LINE\Clients\MessagingApi\Model\AudioMessage;
use LINE\Clients\MessagingApi\Model\ReplyMessageRequest;
use LINE\Constants\MessageContentProviderType;
use LINE\Constants\MessageType;
use LINE\LINEBot\KitchenSink\EventHandler;
use LINE\LINEBot\KitchenSink\EventHandler\MessageHandler\Util\UrlBuilder;
use LINE\Webhook\Model\AudioMessageContent;
use LINE\Webhook\Model\MessageEvent;
use SplFileObject;

class AudioMessageHandler implements EventHandler
{
Expand Down Expand Up @@ -94,7 +92,6 @@ public function handle()
private function replyAudioMessage(string $replyToken, string $url, int $duration)
{
$message = new AudioMessage([
'type' => MessageType::AUDIO,
'originalContentUrl' => $url,
'duration' => $duration,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use LINE\Clients\MessagingApi\Model\FlexSpan;
use LINE\Clients\MessagingApi\Model\FlexText;
use LINE\Clients\MessagingApi\Model\URIAction;
use LINE\Constants\ActionType;
use LINE\Constants\Flex\BubbleContainerSize;
use LINE\Constants\Flex\ComponentButtonHeight;
use LINE\Constants\Flex\ComponentButtonStyle;
Expand All @@ -44,9 +43,6 @@
use LINE\Constants\Flex\ComponentMargin;
use LINE\Constants\Flex\ComponentSpaceSize;
use LINE\Constants\Flex\ComponentSpacing;
use LINE\Constants\Flex\ComponentType;
use LINE\Constants\Flex\ContainerType;
use LINE\Constants\MessageType;

/**
* @SuppressWarnings("PHPMD.CouplingBetweenObjects")
Expand All @@ -61,10 +57,8 @@ class FlexSampleRestaurant
public static function get(): FlexMessage
{
return new FlexMessage([
'type' => MessageType::FLEX,
'altText' => 'Restaurant',
'contents' => new FlexBubble([
'type' => ContainerType::BUBBLE,
'hero' => self::createHeroBlock(),
'body' => self::createBodyBlock(),
'footer' => self::createFooterBlock(),
Expand All @@ -76,13 +70,11 @@ public static function get(): FlexMessage
private static function createHeroBlock(): FlexComponent
{
return new FlexImage([
'type' => ComponentType::IMAGE,
'url' => 'https://example.com/cafe.png',
'size' => ComponentImageSize::FULL,
'aspectRatio' => ComponentImageAspectRatio::R20TO13,
'aspectMode' => ComponentImageAspectMode::COVER,
'action' => new URIAction([
'type' => ActionType::URI,
'label' => 'cafe hero',
'uri' => 'https://example.com',
'altUri' => new AltUri(['desktop' => 'https://example.com#desktop']),
Expand All @@ -93,14 +85,12 @@ private static function createHeroBlock(): FlexComponent
private static function createBodyBlock()
{
return new FlexBox([
'type' => ComponentType::BOX,
'layout' => ComponentLayout::VERTICAL,
'backgroundColor' => '#fafafa',
'paddingAll' => '8%',
'contents' => [
// Title
new FlexText([
'type' => ComponentType::TEXT,
'text' => 'Brown Cafe',
'weight' => ComponentFontWeight::BOLD,
'size' => ComponentFontSize::XL,
Expand All @@ -114,17 +104,14 @@ private static function createBodyBlock()
private static function createBodyReview(): FlexBox
{
$goldStar = new FlexIcon([
'type' => ComponentType::ICON,
'url' => 'https://example.com/gold_star.png',
'size' => ComponentIconSize::SM,
]);
$grayStar = new FlexIcon([
'type' => ComponentType::ICON,
'url' => 'https://example.com/gray_star.png',
'size' => ComponentIconSize::SM,
]);
$point = new FlexText([
'type' => ComponentType::TEXT,
'text' => '4.0',
'size' => ComponentFontSize::SM,
'color' => '#999999',
Expand All @@ -133,7 +120,6 @@ private static function createBodyReview(): FlexBox
]);

return new FlexBox([
'type' => ComponentType::BOX,
'layout' => ComponentLayout::BASELINE,
'margin' => ComponentMargin::MD,
'contents' => [$goldStar, $goldStar, $goldStar, $goldStar, $grayStar, $point],
Expand All @@ -143,19 +129,16 @@ private static function createBodyReview(): FlexBox
private static function createBodyInfoBlock(): FlexBox
{
$place = new FlexBox([
'type' => ComponentType::BOX,
'layout' => ComponentLayout::BASELINE,
'spacing' => ComponentSpacing::SM,
'contents' => [
new FlexText([
'type' => ComponentType::TEXT,
'text' => 'Place',
'color' => '#aaaaaa',
'size' => ComponentFontSize::SM,
'flex' => 1,
]),
new FlexText([
'type' => ComponentType::TEXT,
'text' => 'Miraina Tower, 4-1-6 Shinjuku, Tokyo',
'wrap' => true,
'color' => '#666666',
Expand All @@ -165,37 +148,31 @@ private static function createBodyInfoBlock(): FlexBox
],
]);
$time = new FlexBox([
'type' => ComponentType::BOX,
'layout' => ComponentLayout::BASELINE,
'spacing' => ComponentSpacing::SM,
'contents' => [
new FlexText([
'type' => ComponentType::TEXT,
'text' => 'Time',
'color' => '#aaaaaa',
'size' => ComponentFontSize::SM,
'flex' => 1,
]),
new FlexText([
'type' => ComponentType::TEXT,
'text' => '10:00 - 23:00',
'wrap' => true,
'color' => '#666666',
'size' => ComponentFontSize::SM,
'flex' => 5,
'contents' => [
new FlexSpan([
'type' => ComponentType::SPAN,
'text' => '10:00',
]),
new FlexSpan([
'type' => ComponentType::SPAN,
'text' => '-',
'color' => '#a0a0a0',
'size' => ComponentFontSize::XS,
]),
new FlexSpan([
'type' => ComponentType::SPAN,
'text' => '23:00',
]),
],
Expand All @@ -204,7 +181,6 @@ private static function createBodyInfoBlock(): FlexBox
]);

return new FlexBox([
'type' => ComponentType::BOX,
'layout' => ComponentLayout::VERTICAL,
'margin' => ComponentMargin::LG,
'spacing' => ComponentSpacing::SM,
Expand All @@ -215,31 +191,26 @@ private static function createBodyInfoBlock(): FlexBox
private static function createFooterBlock()
{
$callButton = new FlexButton([
'type' => ComponentType::BUTTON,
'style' => ComponentButtonStyle::LINK,
'height' => ComponentButtonHeight::SM,
'action' => new URIAction([
'type' => ActionType::URI,
'label' => 'CALL',
'uri' => 'https://example.com',
'altUri' => new AltUri(['desktop' => 'https://example.com#desktop']),
]),
]);
$websiteButton = new FlexButton([
'type' => ComponentType::BUTTON,
'style' => ComponentButtonStyle::LINK,
'height' => ComponentButtonHeight::SM,
'action' => new URIAction([
'type' => ActionType::URI,
'label' => 'WEBSITE',
'uri' => 'https://example.com',
'altUri' => new AltUri(['desktop' => 'https://example.com#desktop']),
]),
]);
$spacer = new FlexSpacer(['type' => ComponentType::SPACER, 'size' => ComponentSpaceSize::SM]);
$spacer = new FlexSpacer(['size' => ComponentSpaceSize::SM]);

return new FlexBox([
'type' => ComponentType::BOX,
'layout' => ComponentLayout::VERTICAL,
'spacing' => ComponentSpacing::SM,
'flex' => 0,
Expand Down
Loading