1919namespace LINE ;
2020
2121use LINE \LINEBot \Event \Parser \EventRequestParser ;
22+ use LINE \LINEBot \Constant \HTTPHeader ;
2223use LINE \LINEBot \HTTPClient ;
2324use LINE \LINEBot \MessageBuilder ;
2425use LINE \LINEBot \MessageBuilder \TextMessageBuilder ;
@@ -170,15 +171,20 @@ public function replyText($replyToken, $text, $extraTexts = null)
170171 * @param string $to Identifier of destination.
171172 * @param MessageBuilder $messageBuilder Message builder to send.
172173 * @param boolean $notificationDisabled Don't send push notifications(=true) or send(=false)
174+ * @param string|null $retryKey UUID(example: 123e4567-e89b-12d3-a456-426614174000) or Not needed retry(=null)
173175 * @return Response
174176 */
175- public function pushMessage ($ to , MessageBuilder $ messageBuilder , $ notificationDisabled = false )
177+ public function pushMessage ($ to , MessageBuilder $ messageBuilder , $ notificationDisabled = false , $ retryKey = null )
176178 {
179+ $ headers = ['Content-Type: application/json; charset=utf-8 ' ];
180+ if (isset ($ retryKey )) {
181+ $ headers [] = HTTPHeader::LINE_RETRY_KEY . ': ' .$ retryKey ;
182+ }
177183 return $ this ->httpClient ->post ($ this ->endpointBase . '/v2/bot/message/push ' , [
178184 'to ' => $ to ,
179185 'messages ' => $ messageBuilder ->buildMessage (),
180186 'notificationDisabled ' => $ notificationDisabled ,
181- ]);
187+ ], $ headers );
182188 }
183189
184190 /**
@@ -187,15 +193,24 @@ public function pushMessage($to, MessageBuilder $messageBuilder, $notificationDi
187193 * @param array $tos Identifiers of destination.
188194 * @param MessageBuilder $messageBuilder Message builder to send.
189195 * @param boolean $notificationDisabled Don't send push notifications(=true) or send(=false)
196+ * @param string|null $retryKey UUID(example: 123e4567-e89b-12d3-a456-426614174000) or Not needed retry(=null)
190197 * @return Response
191198 */
192- public function multicast (array $ tos , MessageBuilder $ messageBuilder , $ notificationDisabled = false )
193- {
199+ public function multicast (
200+ array $ tos ,
201+ MessageBuilder $ messageBuilder ,
202+ $ notificationDisabled = false ,
203+ $ retryKey = null
204+ ) {
205+ $ headers = ['Content-Type: application/json; charset=utf-8 ' ];
206+ if (isset ($ retryKey )) {
207+ $ headers [] = HTTPHeader::LINE_RETRY_KEY . ': ' .$ retryKey ;
208+ }
194209 return $ this ->httpClient ->post ($ this ->endpointBase . '/v2/bot/message/multicast ' , [
195210 'to ' => $ tos ,
196211 'messages ' => $ messageBuilder ->buildMessage (),
197212 'notificationDisabled ' => $ notificationDisabled ,
198- ]);
213+ ], $ headers );
199214 }
200215
201216 /**
@@ -204,14 +219,19 @@ public function multicast(array $tos, MessageBuilder $messageBuilder, $notificat
204219 *
205220 * @param MessageBuilder $messageBuilder Message builder to send.
206221 * @param boolean $notificationDisabled Don't send push notifications(=true) or send(=false)
222+ * @param string|null $retryKey UUID(example: 123e4567-e89b-12d3-a456-426614174000) or Not needed retry(=null)
207223 * @return Response
208224 */
209- public function broadcast (MessageBuilder $ messageBuilder , $ notificationDisabled = false )
225+ public function broadcast (MessageBuilder $ messageBuilder , $ notificationDisabled = false , $ retryKey = null )
210226 {
227+ $ headers = ['Content-Type: application/json; charset=utf-8 ' ];
228+ if (isset ($ retryKey )) {
229+ $ headers [] = HTTPHeader::LINE_RETRY_KEY . ': ' .$ retryKey ;
230+ }
211231 return $ this ->httpClient ->post ($ this ->endpointBase . '/v2/bot/message/broadcast ' , [
212232 'messages ' => $ messageBuilder ->buildMessage (),
213233 'notificationDisabled ' => $ notificationDisabled ,
214- ]);
234+ ], $ headers );
215235 }
216236
217237 /**
@@ -738,13 +758,15 @@ public function revokeChannelAccessToken($channelAccessToken)
738758 * @param RecipientBuilder|null $recipientBuilder
739759 * @param DemographicFilterBuilder|null $demographicFilterBuilder
740760 * @param int|null $limit
761+ * @param string|null $retryKey UUID(example: 123e4567-e89b-12d3-a456-426614174000) or Not needed retry(=null)
741762 * @return Response
742763 */
743764 public function sendNarrowcast (
744765 MessageBuilder $ messageBuilder ,
745766 RecipientBuilder $ recipientBuilder = null ,
746767 DemographicFilterBuilder $ demographicFilterBuilder = null ,
747- $ limit = null
768+ $ limit = null ,
769+ $ retryKey = null
748770 ) {
749771 $ params = [
750772 'messages ' => $ messageBuilder ->buildMessage ()
@@ -762,7 +784,11 @@ public function sendNarrowcast(
762784 'max ' => $ limit
763785 ];
764786 }
765- return $ this ->httpClient ->post ($ this ->endpointBase . '/v2/bot/message/narrowcast ' , $ params );
787+ $ headers = ['Content-Type: application/json; charset=utf-8 ' ];
788+ if (isset ($ retryKey )) {
789+ $ headers [] = HTTPHeader::LINE_RETRY_KEY . ': ' .$ retryKey ;
790+ }
791+ return $ this ->httpClient ->post ($ this ->endpointBase . '/v2/bot/message/narrowcast ' , $ params , $ headers );
766792 }
767793
768794 /**
0 commit comments