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 /**
@@ -802,13 +822,15 @@ public function getChannelAccessToken21Keys($jwt)
802822 * @param RecipientBuilder|null $recipientBuilder
803823 * @param DemographicFilterBuilder|null $demographicFilterBuilder
804824 * @param int|null $limit
825+ * @param string|null $retryKey UUID(example: 123e4567-e89b-12d3-a456-426614174000) or Not needed retry(=null)
805826 * @return Response
806827 */
807828 public function sendNarrowcast (
808829 MessageBuilder $ messageBuilder ,
809830 RecipientBuilder $ recipientBuilder = null ,
810831 DemographicFilterBuilder $ demographicFilterBuilder = null ,
811- $ limit = null
832+ $ limit = null ,
833+ $ retryKey = null
812834 ) {
813835 $ params = [
814836 'messages ' => $ messageBuilder ->buildMessage ()
@@ -826,7 +848,11 @@ public function sendNarrowcast(
826848 'max ' => $ limit
827849 ];
828850 }
829- return $ this ->httpClient ->post ($ this ->endpointBase . '/v2/bot/message/narrowcast ' , $ params );
851+ $ headers = ['Content-Type: application/json; charset=utf-8 ' ];
852+ if (isset ($ retryKey )) {
853+ $ headers [] = HTTPHeader::LINE_RETRY_KEY . ': ' .$ retryKey ;
854+ }
855+ return $ this ->httpClient ->post ($ this ->endpointBase . '/v2/bot/message/narrowcast ' , $ params , $ headers );
830856 }
831857
832858 /**
0 commit comments