Skip to content

Commit e98690a

Browse files
authored
Fix LocationMessageHandler to handle non title or address (#679)
Location Message Webhook sometimes does not have title or address. https://developers.line.biz/en/reference/messaging-api/#wh-location However, when Official Account sends Location Message, title and address is required. https://developers.line.biz/en/reference/messaging-api/#location-message So usually LocationMessageHandler is failed to send message. ``` POST /callback - Uncaught LINE\Clients\MessagingApi\ApiException: [400] Client error: `POST https://api.line.me/v2/bot/message/reply` resulted in a `400 Bad Request` response: {"message":"The request body has 1 error(s)","details":[{"message":"May not be empty","property":"messages[0].title"}]} ``` I've added default value as title and address and fixed it.
1 parent c884132 commit e98690a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/LocationMessageHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public function handle()
5757

5858
$message = new LocationMessage([
5959
'type' => MessageType::LOCATION,
60-
'title' => $this->locationMessage->getTitle(),
61-
'address' => $this->locationMessage->getAddress(),
60+
'title' => $this->locationMessage->getTitle() ?? "default title",
61+
'address' => $this->locationMessage->getAddress() ?? "default address",
6262
'latitude' => $this->locationMessage->getLatitude(),
6363
'longitude' => $this->locationMessage->getLongitude(),
6464
]);

0 commit comments

Comments
 (0)