Skip to content

Commit fcf9da1

Browse files
committed
Add ForwardMessages method
1 parent 9ca1628 commit fcf9da1

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ This method will be called when an incoming message is received. Next, process m
159159
| `sending.sendLocation` | The method is aimed for sending a location message | [SendLocation.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendLocation.md) |
160160
| `sending.sendMessage` | The method is aimed for sending a text message to a personal or a group chat | [SendMessage.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendMessage.md) |
161161
| `sending.sendTemplateButtons` | The method is aimed for sending a message with template list interactive buttons to a personal or a group chat | [SendTemplateButtons.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendTemplateButtons.md) |
162+
| `sending.forwardMessages` | The method is intended for forwarding messages to a personal or group chat | [ForwardMessages.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/ForwardMessages.md) |
162163
| `serviceMethods.checkWhatsapp` | The method checks WhatsApp account availability on a phone number | [CheckWhatsapp.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/CheckWhatsapp.md) |
163164
| `serviceMethods.getAvatar` | The method returns a user or a group chat avatar | [GetAvatar.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/GetAvatar.md) |
164165
| `serviceMethods.getContactInfo` | The method is aimed for getting information on a contact | [GetContactInfo.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/GetContactInfo.md) |

README_RUS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ body | тело сообщения (json)
157157
| `sending.sendLocation` | Метод предназначен для отправки сообщения геолокации | [SendLocation.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendLocation.md) |
158158
| `sending.sendMessage` | Метод предназначен для отправки текстового сообщения в личный или групповой чат | [SendMessage.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendMessage.md) |
159159
| `sending.sendTemplateButtons` | Метод предназначен для отправки сообщения с интерактивными кнопками из перечня шаблонов в личный или групповой чат | [SendTemplateButtons.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendTemplateButtons.md) |
160+
| `sending.forwardMessages` | Метод предназначен для пересылки сообщений в личный или групповой чат | [ForwardMessages.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/ForwardMessages.md) |
160161
| `serviceMethods.checkWhatsapp` | Метод проверяет наличие аккаунта WhatsApp на номере телефона | [CheckWhatsapp.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/CheckWhatsapp.md) |
161162
| `serviceMethods.getAvatar` | Метод возвращает аватар корреспондента или группового чата | [GetAvatar.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/GetAvatar.md) |
162163
| `serviceMethods.getContactInfo` | Метод предназначен для получения информации о контакте | [GetContactInfo.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/GetContactInfo.md) |

src/tools/Sending.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,4 +373,29 @@ public function sendTemplateButtons(
373373
return $this->greenApi->request( 'POST',
374374
'{{host}}/waInstance{{idInstance}}/SendTemplateButtons/{{apiTokenInstance}}', $requestBody );
375375
}
376+
377+
/**
378+
* The method is intended for forwarding messages to a personal or group chat. The forwarded messages will be added
379+
* to the send queue. Checking whatsapp authorization on the phone (i.e. availability in linked devices) is not performed.
380+
* The message will be kept for 24 hours in the queue and will be sent immediately after phone authorization.
381+
* The rate at which messages are sent from the queue is managed by Message sending delay parameter.
382+
*
383+
* @param string $chatId
384+
* @param string $chatIdFrom
385+
* @param array $messages
386+
*
387+
* @return stdClass
388+
* @link https://green-api.com/en/docs/api/sending/ForwardMessages/
389+
*/
390+
public function forwardMessages( string $chatId, string $chatIdFrom, array $messages ): stdClass {
391+
392+
$requestBody = [
393+
'chatId' => $chatId,
394+
'chatIdFrom' => $chatIdFrom,
395+
'messages' => $messages
396+
];
397+
398+
return $this->greenApi->request( 'POST',
399+
'{{host}}/waInstance{{idInstance}}/ForwardMessages/{{apiTokenInstance}}', $requestBody );
400+
}
376401
}

0 commit comments

Comments
 (0)